-1

我正在使用 php-facebook sdk 实现 facebook 登录。但我没有从 facebook 获取用户的电子邮件地址,以及在 facebook 上新创建的应用程序。

这是权限设置页面上的屏幕截图

这是授权对话框的预览

这是实际的身份验证对话框渲染

根据所附图片,我们已对以下电子邮件的权限设置进行了更改。当我预览身份验证对话框时,facebook 在对话框中显示电子邮件权限。但是在运行站点身份验证对话框时,没有显示电子邮件权限,也没有给出返回的电子邮件。

提前感谢您的帮助。

4

2 回答 2

2

set your scope (permission) in the app settings

also refer this :

    $facebook = new Facebook(array(
                'appId' => 'xxxxxxxxxxxxxxxxxxxxxx',
                'secret' => 'xxxxxxxxxxxxxxxxxxxxx',
            ));
    $facebookUser = $facebook->getUser();
    $fbLogoutUrl = $facebook->getLogoutUrl();
    if ($facebookUser) {
      try {
        $fbUserProfile = $facebook->api('/me');
      } catch (FacebookApiException $e) {
        error_log($e);
        $user = null;
      }
      if (!empty($fbUserProfile)) {
        $fbUserId = $fbUserProfile ['id'];
        $fbUserEmail = $fbUserProfile ['email'];
      }
    } else {
      $fbLoginUrl = $facebook->getLoginUrl(array('scope' => 'email,publish_stream,user_photos,photo_upload,offline_access'));
      header("Location: " . $fbLoginUrl);
    }

Regards : TechNew.In

于 2012-10-17T12:42:01.280 回答
1

That's not how you configure permissions for use with the PHP SDK.

Those settings are for the App Center only (Authenticated Referrals have been removed)

This is one way you can add permissions within the SDK,

$params = array(
  'scope' => 'email',
  'redirect_uri' => 'https://www.myapp.com/post_login_page'
);

$loginUrl = $facebook->getLoginUrl($params);

See more at: http://developers.facebook.com/docs/reference/php/facebook-getLoginUrl/
And: https://developers.facebook.com/docs/opengraph/authentication/#referrals

于 2012-10-17T12:41:27.687 回答