2

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?

Cyrus
  • 3,687
  • 5
  • 35
  • 67
  • impossible even with an access_token. Facebook is very protective on emails. try getting friend_emails and you will see there is no such option – naveen Aug 24 '12 at 07:25
  • i'm not trying to get the email address out. i'm trying to provide an email address and get an id. – Cyrus Aug 24 '12 at 07:27
  • i understood that pal. i usually save the users facebook_id and email in the database so that it makes retrieval easier... – naveen Aug 24 '12 at 07:38
  • gotcha. thanks for your help :) i guess i'll have to see if i can convince folks to use something like gravatar. – Cyrus Aug 24 '12 at 07:41

2 Answers2

2

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.

Niraj Shah
  • 15,087
  • 3
  • 41
  • 60
0

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.

cpilko
  • 11,792
  • 2
  • 31
  • 45