我正在與Facebook API第一次工作。從我找到的文檔中我們可以獲取如下名稱 console.log(response.name); 但我怎樣才能也可以獲取電子郵件和fbid?如何獲得用戶電子郵件和fd編號使用facebook登錄使用圖形api
感謝, Enamul
<?php ?>
<div id="fb-root"></div>
<script>
// Additional JS functions here
window.fbAsyncInit = function() {
FB.init({
appId : 'f', // App ID
channelUrl : '//localhost/practices/phpTest/fblogin/login.php/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// connected
} else if (response.status === 'not_authorized') {
// not_authorized
login();
} else {
// not_logged_in
login();
}
});
// Additional init code here
};
function login() {
FB.login(function(response) {
if (response.authResponse) {
// connected
testAPI();
} else {
// cancelled
}
});
}
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
});
}
// Load the SDK Asynchronously
(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));
</script>
<?php ?>
你是否穿過?如果不是,則評論__如果是,則接受答案。 – ThePCWizard 2013-03-07 13:32:12
@ThePCWizard抱歉遲到接受。我離開了一段時間,所以我無法測試它。 – user1559230 2013-03-08 05:47:24