简体   繁体   English

从登录获取Facebook电子邮件地址

[英]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. 尽管已授予权限,但响应仅具有_IDname

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.

相关问题 Facebook 登录回调返回姓名但不返回电子邮件地址 - Facebook login callback returns name but not email address 无法从Facebook登录名获取电子邮件(API版本2.8) - Can't Get Email from Facebook Login(API Version 2.8) Windows Live登录获取电子邮件地址 - windows live login get email address Facebook API - OAUTH 登录屏幕保留用户 email 地址 - Facebook API - OAUTH login screen retains user email address 使用Facebook Firebase简单登录获取电子邮件 - Get email with Facebook Firebase Simple Login 使用Facebook登录获取用户名,电子邮件 - Login using facebook get username, email Keycloak-从身份提供商登录名获取电子邮件地址,而无需创建新帐户 - Keycloak - Get email address from Identity Provider Login without creating a new account 我无法从我网站上的Facebook登录名获取电子邮件范围 - I can't get the email scope from facebook login on my website to work 用facebook登录将电子邮件,国家(地区),…,全名从facebook保存到数据库 - save email, country, …, full name from facebook to database with login with facebook 无法通过分析Facebook登录获取用户的电子邮件 - Unable to get user's email with Parse Facebook login
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM