How to get a facebook user id from the login email address

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 03:01:52

问题


Is there a way to get a user's facebook user id from their login email address?

I want an API call where I can provide joe@example.com and get facebook user id 342255534.

I'll use that id to call http://graph.facebook.com/342255534/picture?type=large

The closest thing I've found is https://graph.facebook.com/search?q=EMAILADDRESS&type=user&access_token=ACCESSTOKEN, but that requires an access token, which I'm hoping to avoid.

I know this isn't how it's supposed to work, but is there a way to get a generic access token?


回答1:


You can use your own access_token for the application, and change it to a long-lived access token so you can make the API call in a cron. The only issue is that you will have to login to the app every so often to update the access token.

UPDATE: The User Search API is now deprecated, so you cannot search using email addresses. But name based searches still work.




回答2:


You can create an app and get an access token for that app. Instructions are here: https://developers.facebook.com/docs/authentication/applications/

Unfortunately, a search for a user_id by email only works with a user access token.

You don't need to be friends with a user to get their id by email address.



来源:https://stackoverflow.com/questions/12104873/how-to-get-a-facebook-user-id-from-the-login-email-address

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