⽤
js
实现
登录获取⽤户的信息(包括邮箱)
//要挂代理
// 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();
}
});
};
(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() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
//for(var i in response)
//{
//console.log(i+":"+response[i]);
//}
retrieveProfiles(response['id']);
});
}