問題があります。$ user_profile = $ facebook-> api('/ me'); 動作している場合と動作していない場合があります。
10件中8件で機能していて、突然$user_profileに空の文字列があります。魔法はどこにありますか?
(私は最新のphp SDKを実装しています)
// 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");
}