0

初めてブラウザで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);
4

1 に答える 1

0

SDKはFacebookユーザーIDとアクセストークンをセッションに保存するため、Cookieをクリアするか、ブラウザを再度開いていない限り、getUserは認証後に0を返しません。

destroySession()SDKのCookieを削除するために呼び出すこともできます。

于 2012-05-14T14:05:22.343 に答える