Facebook Graph API - authorization types?

后端 未结 5 1342
南旧
南旧 2021-02-10 22:34

I\'m struggling with the new Facebook Graph API, perhaps someone here can help.

Here is what I want to do: provide a ‘login w/ FB’ button, throw to /authorize, get a cod

5条回答
  •  庸人自扰
    2021-02-10 23:04

    I had the same problem and I solved it.

    First: Dont use &type=client_cred.

    Second: Use the same URL everywhere!!!

    My example:

    My firs link:

    FB login  
    

    When I got the code:

    $nexturl  = "https://graph.facebook.com/oauth/access_token?client_id=".$AppId."&redirect_uri=http://mysite.ru/ru/site_users.html?op=fbreg&client_secret=".$AppSec."&code=".$fbCode;
    $response = @file_get_contents($nexturl);   
    $params   = null;
    parse_str($response, $params);
    $graph_url = "https://graph.facebook.com/me?access_token=".$params['access_token'];
    $arrResponse = json_decode(@file_get_contents($graph_url));
    

    In $arrResponse i got all info about current user.

    The value of URL should be the same everywhere. In the code and in https://developers.facebook.com/apps/.

    In my case it is this: http://mysite.ru/ru/site_users.html?op=fbreg

    The following are all incorrect using my example.

    • http://mysite.ru/
    • http://mysite/
    • http://mysite/ru/site_users.html

    Thats all. Very stupid problem. I solved it for three days :(

提交回复
热议问题