I am using the FB PHP SDK along with Code Igniter 2 Framework.
I have a registration page where I can display a link for the user to click and approve the app and give it access to their basic data and email. This seems to work fine (although I have set it to be a popup, it doesn't popup, it just shows in the same page!).
My problem is that after being logged in with FB, the page shows a logout link, which when click, should log them out (and therefore show the login link again) BUT it doesn't work.
I have a parameter set to take it page to a certain page, and that does work. Just for some reason the FB "session" stick around and the user stays logged in with FB.
Any ideas?
my code in my controller:
// Facebook Connect
$fb_config = array(
'appId' => 'xxx',
'secret' => 'xxx'
);
$this->load->library('facebook', $fb_config);
$user = $this->facebook->getUser();
if ($user) {
try {
$data['user_profile'] = $this->facebook->api('/me');
} catch (FacebookApiException $e) {
$user = null;
}
}
if ($user) {
$params = array('next' => 'http://localhost/game/index.php/game/login');
$data['logout_url'] = $this->facebook->getLogoutUrl($params);
} else {
$params = array('scope' => 'email, publish_stream, publish_actions', 'display' => 'popup');
$data['login_url'] = $this->facebook->getLoginUrl($params);
}
Last little question - should I even be using the PHP SDK, or should I use the Javascript SDK? I cant find any info on which one is best for whatever job?! Confused.com
should I even be using the PHP SDK, or should I use the Javascript SDK?
If your app can be created with the JavaScript SDK instead of the PHP SDK, then go for it. Save your server's CPU cycles for something else. It also allows you to perform login asynchronously which can be nice.
Complex apps usually use both the JavaScript SDK and the PHP SDK -- in which case login is often handled on the Javascript side (the PHP SDK automatically knows if the user logged in via JavaScript).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With