问题
Here I'm simply sending a GET request through a rest client.It returns only user id and name .Additionally, how do I retrieve user's email using only a GET request?
https://graph.facebook.com/me?access_token= [User's access token]
回答1:
https://graph.facebook.com/me?fields=name,email&access_token=[User's access token]
It´s called "Declarative Fields" and came with v2.4 of the Graph API: https://developers.facebook.com/docs/apps/changelog#v2_4
API Explorer test: https://developers.facebook.com/tools/explorer/?method=GET&path=me%3Ffields%3Dname%2Cemail
Of course you need to use a User Token that includes the email
permission/scope. Debug your Token here: https://developers.facebook.com/tools/debug/accesstoken/
回答2:
I know this is sort of an old question, but just so anyone else misses it: even if you give permission when generating the token, if the user doesn't have an email registered to his/her facebook account or hasn't confirmed the email yet, facebook won't return it when you query.
You can see this on the Graph API Explorer:
Hope this helps :)
来源:https://stackoverflow.com/questions/37349618/in-facebook-graph-api-what-are-the-api-calls-to-get-a-users-email-address