jeudi 24 octobre 2019

How to get profile info from facebook API

The api API manual is very confusing. I have been searching a simple example - how to use facebook OAuth on my website, but still can not find solution. My steps:

1 - I send user from mywebsite to facebook oauth like this ::

https://graph.facebook.com/oauth/authorize?
client_id={my_app_id}&
redirect_uri=my_website_url}&
scope=public_profile

2 - then client is writing his login/pass to facebook 3 - facebook is redirecting client to {my_website_url} with code parameter like this :

code=AQBT1fi07BMmAFdOR0xCq...bfdOR0xf#_=_

4 - I try ro use code to get public profile data like this :

https://graph.facebook.com/me?
fields=id,name,birthday,gender,picture&
access_token={`code`}

but responce from facebook looks like OAuthException :

{
    "error": {
        "message": "Malformed access token AQBT1fi07BMmAFd63cECQcS...BLa",
        "type": "OAuthException",
        "code": 190,
        "fbtrace_id": "Abea9iHXYTbMPyyemC_yu6y"
    }
}

How can I fix it ?




Aucun commentaire:

Enregistrer un commentaire