php 从他们的 FB ID 获取 Facebook 用户电子邮件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14698254/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Get Facebook User Email from their FB ID
提问by Jo Smith
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.
基本上,我有一个 iPhone 应用程序,用户可以在其中使用 Facebook 登录。当他们这样做时,他们的 Facebook ID 被发送到服务器并用作他们的用户 ID(而不是他们的电子邮件,如果他们使用电子邮件登录)。现在,如果我想在新用户第一次注册/登录时向他们发送电子邮件,我如何从发送到服务器的 ID 中获取 Facebook 用户的电子邮件。我确实拥有 Facebook 的电子邮件权限,但我不知道如何仅从他们的 ID 中获取用户的电子邮件。
Is this possible?
这可能吗?
回答by cpilko
Instead of sending the user_idto 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.
user_id当他们在您的应用程序上进行身份验证时,不要将 发送到您的服务器,而是发送access_token. 然后,您可以使用该令牌查询 API 并获取他们授权您拥有的所有数据。
Bonus: It's almost impossible for someone to spoof a valid access token issued to your app.
额外奖励:某人几乎不可能伪造颁发给您的应用程序的有效访问令牌。
回答by William N
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
你需要给它变量:facebook->api('/me/email')
编辑:这里有一篇文章:Facebook Graph API,如何获取用户的电子邮件?阅读第二个答案

