soichi Posted April 6, 2013 Share Posted April 6, 2013 PHP 5.3.1 latest facebook-php-sdk https://github.com/facebook/facebook-php-sdk Currently I am working on Facebook web application which requires an authentication to extract fb information. The authentication process is of course to be done when users intend to login. But I need to split files so that maintenance of codes would be easier. More specifically, I want to have a single file.php that is responsible for the authentication, and other files read objects or whatever necessary from it in order to apply various functions to the application. the authentication goes like, switch(getenv("SERVER_NAME")) { case "xxx" define('FACEBOOK_APP_ID', ''); define('FACEBOOK_APP_SECRET', ''); define('HTTP_ROOT', 'http://xxx.facebookapp/'); define('DB_HOST', 'localhost'); define('DB_USER', 'root'); define('DB_PASSWORD', ''); define('DB_DATABASE', 'xxx'); break; } $facebook = new Facebook(array( 'appId' => FACEBOOK_APP_ID, 'secret' => FACEBOOK_APP_SECRET, )); I need this "$facebook" object in many other files. Somehow this part will be in an independent file, and other files refer to the object. Is it possible to do it? Can anyone help me out? soichi Quote Link to comment https://forums.phpfreaks.com/topic/276606-split-facebook-authentication-code-from-other-functions/ Share on other sites More sharing options...
trq Posted April 6, 2013 Share Posted April 6, 2013 I'm not sure I understand the issue. You have created $facebook within the global namespace so it is available everywhere within that scope. Just include this file where ever you need to. Quote Link to comment https://forums.phpfreaks.com/topic/276606-split-facebook-authentication-code-from-other-functions/#findComment-1423255 Share on other sites More sharing options...
soichi Posted April 6, 2013 Author Share Posted April 6, 2013 thanks. it's easier than I thought. Quote Link to comment https://forums.phpfreaks.com/topic/276606-split-facebook-authentication-code-from-other-functions/#findComment-1423259 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.