[英]Get facebook email address from login
I'm currently using hello.js to have users create accounts and sign in with facebook. 我目前正在使用hello.js让用户创建帐户并使用Facebook登录。 However, I need to use the user's facebook email address since this is used to send the user a confirmation of purchase.
但是,我需要使用用户的Facebook电子邮件地址,因为该地址用于向用户发送购买确认。
Because the user can choose to not allow us to have his/her email address, I am left with an empty slot, thus the user never receiving confirmation of orders or downloadable files purchased through the system. 因为用户可以选择不允许我们使用他/她的电子邮件地址,所以我留下了一个空位,因此用户永远不会收到通过系统购买的订单或可下载文件的确认。
I've tried using the facebook user ID, but the email format is username@facebook.com
. 我尝试使用Facebook用户ID,但是电子邮件格式为
username@facebook.com
。 I can retrieve the user's ID and email (if allowed), but not the username. 我可以检索用户的ID和电子邮件(如果允许),但不能检索用户名。
Can we retrieve this and if so, how ? 我们可以检索这个吗?
I scratched my head too on how to fetch emails from FB, cause the response object in the documentation [ https://developers.facebook.com/docs/facebook-login/web] paragraph Make API calls looks different from what it is returned. 我也为如何从FB获取电子邮件而费了点劲,导致文档[ https://developers.facebook.com/docs/facebook-login/web]段落中的响应对象使API调用看起来与返回的内容有所不同。
You may want to look at: [ https://developers.facebook.com/docs/javascript/reference/FB.api] and add parameters. 您可能需要查看:[ https://developers.facebook.com/docs/javascript/reference/FB.api]并添加参数。
Here using version 2.5: 这里使用版本2.5:
window.fbAsyncInit = function() {
FB.init({
appId : {your-app-id},
status : true,
cookie : true,
xfbml : true,
oauth : true,
version : 'v2.5'
});
Following the documentation, once logged: 遵循文档,一旦记录:
FB.api('/me', function(response) {console.log(response) })
response has only _ID
and name
despite permissions are granted. 尽管已授予权限,但响应仅具有
_ID
和name
。
You can retrieve the email, if existing , by also specifying fields
parameters against FB.api
: 你可以检索电子邮件, 如果存在的话 , 也通过指定
fields
对参数FB.api
:
FB.api('/me?fields=id,name,email', function(response) { console.log(response); });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.