In Facebook Graph API, what are the API calls to get a user's email address

妖精的绣舞 提交于 2020-01-04 05:56:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!