我想获取来自Facebook好友的所有访问的数据的数据(仅姓名,生日,性别,现在是足以让我)。我的用户在App ID,我需要的只是公开的数据,所以我尝试了一些代码,但我只得到名称和Facebook的ID。 请提出我应该在我的代码中做什么?FQL查询来获取Facebook好友
function statusChangeCallback(response) {
console.log('statusChangeCallback');
console.log(response);
if (response.status === 'connected') {
testAPI();
} else if (response.status === 'not_authorized') {
document.getElementById('status').innerHTML = 'Please log ' + 'into this app.';
} else {
document.getElementById('status').innerHTML = 'Please log ' + 'into Facebook.';
}
}
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
window.fbAsyncInit = function() {
FB.init({
appId : '155509608142654',
cookie : true, // enable cookies to allow the server to access
// the session
xfbml : true, // parse social plugins on this page
version : 'v2.5' // use version 2.2
});
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
};
// Load the SDK asynchronously
(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 = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}
(document, 'script', 'facebook-jssdk'));
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me?fields=name,friends{age_range,birthday,gender}', function(response) {
console.log(response);
document.getElementById('userDetails').innerHTML = 'Thanks for logging in, ' + response.name + ' below are your information!' + '<br><b>Name:</b>' + response.name +'<br><b>frnd:</b>' + response.friendgender + '<br><b>frnd list:</b>' + response.friendlists + '<br><b>Facebook link:</b>' + response.link + '<br><b>Local:</b>' + response.location + '<br><b>Facebook Id:</b>' + response.id;
>
首先,就是_not_ FQL,但一个正常的图形API调用。而且你不能通过API获取任何你喜欢的关于朋友的信息,大部分内容都需要朋友的许可。 – CBroe