Getting a facebook profile picture from an email address

前端 未结 3 1056
难免孤独
难免孤独 2020-12-28 08:35

I\'m trying to get a user\'s facebook profile picture based on their email address. Effectively, I want to offer my users the option between using Gravatar for their image,

相关标签:
3条回答
  • 2020-12-28 09:00

    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

    0 讨论(0)
  • 2020-12-28 09:00

    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...

    0 讨论(0)
  • 2020-12-28 09:16

    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.

    0 讨论(0)
提交回复
热议问题