1

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?

Jo Smith
  • 67
  • 1
  • 3
  • 10

2 Answers2

4

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.

cpilko
  • 11,792
  • 2
  • 31
  • 45
  • Okay, that's what I feared. I was hoping to not have to resubmit my app but oh well. Thanks. (I'll wait a little longer to accept the best answer though). – Jo Smith Feb 05 '13 at 09:32
1

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

Community
  • 1
  • 1
William N
  • 432
  • 4
  • 12
  • Sorry, but I don't understand either of those. The user is not 'signed in' on the server (they signed in on the app, which sent the facebook id only to the server), so that means I cant use the post you linked. Right? – Jo Smith Feb 05 '13 at 01:06
  • You can use the access token your mobile app received when you authenticated the user to retrieve their email address. You can do this in your mobile app and send the email to your server, or send the access token to your server and use that to query the API from your server – Igy Feb 05 '13 at 07:31