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

admin5年前IT技术1590

由于公司英语商城要做免注册登录,我就想到了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

 

相关文章

windows下安装、卸载mysql服务

windows下安装、卸载mysql服务2012年03月09日 16:30:20阅读数:52062 将下载下来的mysql解压到指定目录下(如:d:\mysql)安装服务 在命令行输入d:\...

KindEditor的图片仓库绑定用户ID的方法

在新建目录的时候,只能一个一个的建立,不能一次性的建两个目录或者在空目录路径之后新建目录...

adobe验证屏蔽

127.0.0.1 lmlicenses.wip4.adobe.com  127.0.0.1 lm.licenses.adobe.com  127.0.0.1...

女白领发量剩3成 中医:遗传加上压力大常熬夜|女白|领发-社会资讯-川北在线

女白领发量剩3成 中医:遗传加上压力大常熬夜 江苏南京一公司女白领,今年25岁。她因遗传原因,加上平时工作压力大,经常熬夜,脱发严重,现在发量只剩30%。中医魏跃钢说,国内脱发人数非常庞大,多数是20...

magento1.x开启调试模式

magento1.x开启调试模式

方法一设置:Current Configuration Scope: main website 通过后台控制台来操作,admin->configuration->develope...

php缓存技术

<?php for($i=0;$i<=5;$i++){echo $i."<br/>";ob_flush();//这里是刷新php缓冲区flush();//这...

发表评论    

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