Jo Smith
Jo Smith

Reputation: 67

Get Facebook User Email from their FB ID

I have spent hours looking for a solution and have finally given up. I'm hoping someone can help me.

Basically, I have an iPhone App where users can sign in with Facebook. When they do this their Facebook ID is sent to the server and is used as their userID (instead of their email, if they sign in with email). Now, if I want to email new users when they register/sign-in for the first time, how can I get the facebook user's email from the ID sent to the server. I do have email permissions from Facebook, but I have no idea how to get the user's email from their ID alone.

Is this possible?

Upvotes: 1

Views: 28399

Answers (2)

cpilko
cpilko

Reputation: 11852

Instead of sending the user_id to your server when they authenticate on your app, send the access_token. You can then query the API with that token and get all of the data they've authorized you to have.

Bonus: It's almost impossible for someone to spoof a valid access token issued to your app.

Upvotes: 4

William N
William N

Reputation: 430

You need to give it variable: facebook->api('/me/email')

edit: a post here: Facebook Graph API, how to get users email? read the second answer

Upvotes: 1

Related Questions