Getting a facebook profile picture from an email address

▼魔方 西西 提交于 2019-11-30 02:01:47

I see this question has a couple of years already but the same search approach can be taken using the Graph API:

GET https://graph.facebook.com/search?q={EMAIL}&type=user

You can try this on the Graph API Explorer. You don't get the profile picture directly but you get the user id which you can easily use to get the public profile picture.

https://graph.facebook.com/{UID}/picture

There doesn't seem to be an official way to do what you are asking. It seems like facebook has made this closed on purpose, probably something to do with privacy. Its actually really easy to do this in a few screen-scraping steps though:

1) Visit http://www.facebook.com/#!/search.php?q=#{USERS_EMAIL_ADDRESS}&type=all&init=srp

2) If page returns "No results found for your query.", then they don't have a profile.

3) Otherwise, the page will contain a thumbnail of the user for that email address. (something like http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs227.ash2/48219_72120057_3223_q.jpg)

I could write a sinatra app to do this in about 5 minutes, if anyone would like me to.

But I think gravatar and facebook should just be friends.

What you're asking to do is part of why Facebook Connect exists.

Using their not-too-cleverly-named XFBML you can request the image directly: <fb:profile-pic uid="1256100362" facebook-logo="true" size="thumb"> </fb:profile-pic>

But you have to implement logins with FB Connect first...

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