暂存范围无效,但在本地工作

时间:2019-06-11 19:46:56

标签: php facebook facebook-graph-api facebook-login php-curl

我想对我的网站实施Facebook登录。这个网站是我自己学习的,这就是为什么我不使用facebook php依赖项的原因。我已经做到了,但是在2.3版本中,我选择了最新的版本:3.3版本,并且我的应用正在运行(未处于测试模式)

我开始只是获取基本配置文件(仅姓氏,名字和Facebook ID)。所有工作均按预期进行。 完成后,我以为我的应用程序已配置好,然后我玩了facebook playground来发现权限和图形字段。

出现第一个问题:我无法(在操场上)得到我的朋友名单。我在我的脚趾上获得了“朋友”权限,然后就获得了该ID的朋友列表,总是收到以下错误消息:

{
  "error": {
    "message": "(#33) This object does not exist or does not support this action",
    "type": "OAuthException",
    "code": 33,
    "fbtrace_id": "DLbDoKNTwEh"
  }
}

这并不是很重要,我决定将其放在一边:我禁用了它。然后,在没有好友列表作用域的情况下,所有一切都在我的本地服务器中正常运行:我决定将其推送到我的登台服务器(heroku应用程序)。然后我在我的facebook配置中有了回调URL。 而且,我很成功地在heroku服务器上登录了我的facebook帐户。 以下类方法允许我管理社交API。因此,方法会将用户重定向到网址,以从返回的代码中获取社交令牌:

private function getRedirectURL(Social $social){
        return File::fromRoot(Folder::getVersionFolder().'redirections/'.$social->getType().'.php')->getUrl(['protocol' => 'https']);
    }


    public function attemptLogin($social = null){
        $social = Social::get($social);

        switch(Social::TYPES[$social->getType()]){
            case Social::TYPES['facebook']:
                return 'https://www.facebook.com/v3.3/dialog/oauth?client_id=' . CONFIG::SOCIAL['facebook']['id'] . '&redirect_uri='.$this->getRedirectURL($social).'&scope=user_birthday,user_hometown,user_location,user_photos,user_friends,user_gender,user_link,user_age_range,email,public_profile';
                break;
            case Social::TYPES['instagram']:
                return 'https://api.instagram.com/oauth/authorize/?client_id='.CONFIG::SOCIAL['instagram']['id'].'&redirect_uri='.$this->getRedirectURL($social).'&response_type=code';
                break;
            case 'google':
                return 'https://accounts.google.com/o/oauth2/v2/auth?redirect_uri='.$this->getRedirectURL($social).'&prompt=consent&response_type=code&client_id='.CONFIG::SOCIAL['google']['id'].'&scope=https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile&access_type=offline';
                break;


        }

        return Folder::fromRoot(Folder::getVersionFolder())->getUrl();
    }

当我尝试登录时,此链接向我返回此错误:

  

无效范围:user_birthday,user_hometown,user_location,user_photos,user_friends,user_gender,user_link,user_age_range。此消息仅显示给开发人员。您的应用程序用户将忽略这些权限(如果存在)。请通过以下网址阅读文档以获取有效权限:https://developers.facebook.com/docs/facebook-login/permissions

0 个答案:

没有答案