//要挂代理
<html><body>
<div id="fb-root"></div><script>
// Additional JS functions here
window.fbAsyncInit = function() {
var facebookId;var facebookName;
var facebookEmail;
FB.init({
appId : 你网站上的id, // App ID
channelUrl : '用facebook登录后返回页面的URL', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.Event.subscribe('auth.authResponseChange', function(response) {
if (response.status === 'connected') {
//测试返回出来的值
testAPI();} else if (response.status === 'not_authorized') {
FB.login();
} else {
FB.login();
}
});
};
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));
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
//for(var i in response)
//{
//console.log(i+":"+response[i]);
//}
retrieveProfiles(response['id']);
});
}
function retrieveProfiles(id) {
// 通过Facebook API 查询用户信息
FB.api({ method: 'fql.query', query: "SELECT uid,email, name, pic_square, books, movies, music, current_location FROM user WHERE uid="+id}, function(response) {
for(var i in response)
{
//显示用户的信息
for(var j in response[i])console.log(j+":"+response[i][j]);
}
});
}
</script>
<body>
//红色表示获得网站访问用户邮箱的权限
<fb:login-button show-faces="true" width="200" max-rows="1" scope="email,user_checkins"></fb:login-button></body></html>