我有樣本Facebook登錄的實現,只是意識到它停止工作:Facebook的連接:JavaScript的登錄會話,但PHP不
<?php
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => 'myappid',
'secret' => 'mybigsecreet',
'cookie' => true,
));
// We may or may not have this data based on a $_GET or $_COOKIE based session.
//
// If we get a session here, it means we found a correctly signed session using
// the Application Secret only Facebook and the Application know. We dont know
// if it is still valid until we make an API call using the session. A session
// can become invalid if it has already expired (should not be getting the
// session back in this case) or if the user logged out of Facebook.
$session = $facebook->getSession();
$me = null;
// Session based API call.
if ($session) {
try {
$uid = $facebook->getUser();
$me = $facebook->api('/me');
$r = new registro_usuarios();
$r->facebook($uid,$me['name'],'https://graph.facebook.com/'.$me['id'].'/picture');
echo '----------------------------'.$me;
} catch (FacebookApiException $e) {
error_log($e);
echo '----------------------------'.$e;
}
}else echo 'nosession';
echo $session;
打印nosesion
但是當我點擊登錄按鈕(臉譜)螢火日誌:FB.login() called when user is already connected.
和登錄彈出(臉書)不會打開。
我錯過了什麼? facebook-api一年後過時了嗎?
非常感謝。會嘗試讓你知道。他們不應該重新映射這個功能嗎? – 2012-03-23 08:14:20
您可以通過'$ facebook-> getUser()'檢查會話。如果它給0,那麼沒有活動會話。這就是爲什麼'$ facebook-> getSession()'函數被棄用的原因。沒有必要映射功能與另一個。 – 2012-03-23 08:54:58
所以我需要再次下載SDK的權利? – 2012-03-23 11:03:14