0
我有用戶登錄在我的網站上實現。到目前爲止,這工作很好。當我嘗試使用Facebook帳戶登錄時,我總是從GetUser()中獲得0。我嘗試了不同的Web瀏覽器,更新PHP SDK到最新版本,但仍然無法正常工作。任何線索?Facebook GetUser()返回0,沒有任何我的代碼更改
$facebook = new Facebook(array(
'appId' => 'my APP ID',
'secret' => 'my Secret',
'cookie' => false, // enable optional cookie support
));
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
$likes = $facebook->api("/me/likes/ID HIDDEN");
if (!isset($_SESSION['prijavljen'])) {
$_SESSION['prijavljen'] = True;
}
if (!empty($likes['data'])) $fblike = true; else $fblike = false;
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
// Login or logout url will be needed depending on current user state.
if ($user) {
//$logoutUrl = $facebook->getLogoutUrl();
$logoutUrl = $facebook->getLogoutUrl(array('next' => 'my URL'));
} else {
$params = array('scope' => 'email,user_birthday,user_education_history,user_hometown,user_likes', 'redirect_uri' => curPageURL());
$loginUrl = $facebook->getLoginUrl($params);
}
你檢查了[Google](https://www.google.com/search?%7Bgoogle:acceptedSuggestion%7Doq=facebook+getuser+returns+0&%7Bgoogle:instantFieldTrialGroupParameter%7Dsourceid=chrome&ie=UTF-8&q=facebook + getuser +返回+ 0&hl = en)這個非常常見的問題? –
是的,我檢查了谷歌,但沒有解決方案的作品:( – B0ris