[英]getuser function return 0 at first time in browser when facebook login in php sdk suddenly
第一次当我在浏览器中登录Facebook。 我调用函数getuser进行检查,但我无法获取它,它仅返回零。 它仅在我第一次打开浏览器时发生。
$facebook = new Facebook(array(
'appId' => 'xxxxx',
'secret' => 'xxxxxxx',
'cookie' => true
));
$here = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$next = preg_replace('~#.*$~s', '', $here);
$next = preg_replace('~\?.*$~s', '', $next);
$next = preg_replace('~/[^/]*$~s', '/login.php', $next);
$params=array(
'scope' => 'publish_stream,user_birthday,read_stream,read_friendlists,user_about_me,email,user_checkins,friends_checkins,publish_checkins,publish_actions',
'redirect_uri' => $next
);
$loginUrl = $facebook->getLoginUrl($params);
SDK会在会话中存储facebook用户ID和访问令牌,因此,除非您清除cookie或像完成操作一样重新打开浏览器,否则getUser在身份验证后不会返回0。
您也可以调用destroySession()
来删除SDK中的cookie。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.