Reputation: 455
I have problem with. $user_profile = $facebook->api('/me'); Sometimes it's working and sometimes it's not.
in 8 of 10 cases it's working and suddenly I have an empty string in $user_profile. Where is the magic?
(I have the newest php SDK implemented)
// FB lib
require_once './libs/facebook.php';
error_reporting(0);
// connect
$facebook = new Facebook(array(
'appId' => 'xxx',
'secret' => 'xxx',
'cookie' => true
));
$user = $facebook->getUser();
$fb_id = $facebook->getUser();
if ($user) {
try {
$_SESSION['user'] = $user_profile = $facebook->api('/me');
$_SESSION['fb_id'] = $fb_id;
} catch (FacebookApiException $e) {
error_log($e);
$user = NULL;
}
}
if ($user == NULL) {
$loginUrl = $facebook->getLoginUrl(
array(
'display' => 'popup',
'scope' => 'publish_stream, user_likes',
'redirect_url' => 'https://xxxx.cz/xxxx/canvas/index.php'
)
);
} else {
$_SESSION['fb_id'] = $fb_id;
header("Location: https://xxxx.cz/xxxx/xxxx.php");
}
Upvotes: 3
Views: 429
Reputation: 650
The magic comes from Facebook , their platform seems to be unstable , you are dependent from their servers which might not work always.
I know that you expect a solution , but really there is only answer to explain why it does not work.
Upvotes: 1