par*_*tho 1 php email facebook facebook-graph-api-v2.4
我想获取用户ID,姓名,电子邮件.获取ID和姓名但不是电子邮件.我有这个代码:
<html>
<head></head>
body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxxxxxxx',
status : true,
cookie : true,
xfbml : true
});
FB.Event.subscribe('auth.authResponseChange', function(response) {
if (response.status === 'connected') {
testAPI();
} else if (response.status === 'not_authorized') {
FB.login();
} else {
FB.login();
}
});
};
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
function testAPI() {
FB.api('/me', function(response) {
console.log(response.name + '---'+response.email);
});
}
</script>
<fb:login-button show-faces="true" width="200" max-rows="1" scope="public_profile,email"></fb:login-button>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
输出是:
FirstName LastName ---未定义
为什么电子邮件未定义?我也希望获得所有信息.怎么样?
我已经尝试使用我的测试应用程序进行编码,但我确实遇到了同样的问题.为了解决这个问题,我尝试了这个,我也能收到电子邮件和全名.
替换为此 -
FB.api('/me?fields=name,email', function(response) {
console.log(response.name + '---'+response.email);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4072 次 |
| 最近记录: |