-7
我试过这段代码来从Facebook获取数据,但我只得到用户的名称和fb ID。我需要我的朋友的一些基本数据,例如AGE,GENDER,LANGUAGE我的查询在开发人员的脸书上工作,但不在Java代码中。 PLZ帮助。 在此先感谢。没有获取数据与fql查询
<script>
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 : '1654526974811057',
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', 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>Gender:</b>' + response.gender + '<br><b>Email:</b>' + response.email + '<br><b>Facebook link:</b>' + response.link + '<br><b>Local:</b>' + response.location + '<br><b>Facebook Id:</b>' + response.id;
var store = [];
var oldf = console.log;
console.log = function(){
store.push(arguments);
oldf.apply(console, arguments);
}
});
}
</script>
<fb:login-button scope="public_profile,email" nonlogin="checkLoginState();" ></fb:login-button>
这不是提问的正确方法。你需要更多的细节 –
试着理解,没有人能看到你的屏幕或知道你在做什么,或者与你描述的任何事情有关。尝试想象*其他人不是你*。然后尝试*描述*您正在做什么,您面临的问题以及您采取的步骤。 – David
寻求调试帮助的问题(“为什么这个代码不工作?”)必须包含所需的行为,特定的问题或错误以及在问题本身中重现问题所需的最短代码。没有明确问题陈述的问题对其他读者无益。请参阅:[如何创建最小,完整和可验证示例](http://stackoverflow.com/help/mcve)。 –