【发布时间】:2012-03-07 21:58:18
【问题描述】:
我有示例 facebook 登录实现,但刚刚意识到它停止工作:
<?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 但是当我单击登录按钮 (facebook) 萤火虫日志:FB.login() called when user is already connected. 并且登录弹出窗口 (facebook) 不会打开。
我错过了什么?一年后facebook-api过时了吗??
【问题讨论】:
标签: php facebook facebook-graph-api facebook-php-sdk facebook-login