facebook登录按钮获取邮箱的方式

admin6年前IT技术2300

由于公司英语商城要做免注册登录,我就想到了facebook,按照官方的文档,一步一步做下去,心情很好,竟然没有坑,但是我高兴的太早了,上线测试了一下发现无法获取用户的邮箱与头像,那有什么用呢.

然后就是查官方,文化差异,那文档就不是写给你中国人看的,最后经过2个多小时的的折腾,终于搞出来了,直接上代码

  (function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "https://connect.facebook.net/en_US/sdk.js";
    fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));

  // Here we run a very simple test of the Graph API after login is
  // successful.  See statusChangeCallback() for when this call is made.
  function testAPI() {
    console.log('Welcome!  Fetching your information.... ');
    FB.api('/me?fields=name,picture,email', function(response) {
      console.log(response);
      document.getElementById('status').innerHTML =
        'Thanks for logging in, ' +response.name+"<br>"+response.email+"<br>"+'<img src="'+ response.picture.data.url + '">';
    });
  }

 

关键是FB.api('/me?fields=name,picture,email', function(response) {

官方竟然没有给出这个M文档!!!!!

官方文档https://developers.facebook.com/docs/facebook-login/permissions/#reference-default

授予您的应用访问User对象的默认字段的权限,这些字段是人员公开个人资料的子集:

  • id
  • first_name
  • last_name
  • middle_name
  • name
  • name_format
  • picture
  • short_name

 

相关文章

mount:is write-protected, mounting read-only解决方案

window10升级之后就遇到mount: **** is write-protected, mounting read-onlymount: cannot mount *** read-only尝试...

二维码生成导航

http://twoyn.shengmake.nethttp://twalabo.shengmake.nethttp://twyilang.shengmake.nethttp://twyindu.sh...

通过IP获取MAC地址

关键知识点:ARP缓存时间是十分钟;实现的命令是:第一步  ping  ip第二部  arp -a基础解释:在底层的网络通信中,两个节点想要相互通信,必须先要知道源与目标...

macbook安装紫鸟的方法

V6 新版(dmg 镜像,推荐)双击 ziniao-xxx.dmg 打开镜像窗口拖拽安装界面把左侧Ziniao 图标拖拽到右侧「应用程序」文件夹打开启动台 / 应用程序,找到紫鸟图标双击启动...

15天学会php视频教程下载

 下载链接百度网盘下载...

国内较大的游戏平台

37\贪玩\悦玩\4399...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。