using FB.data.query not getting any response back
I am trying to get the user gender and birth date through the following:
FB.api('/me', function(response) {
var query = FB.Data.query('开发者_如何学编程select birthday, gender from user where owner={0}',
response.id);
query.wait(function(rows) {
console.log(rows[0].birthday);
console.log(rows[0].gender);
alert(rows[0].birthday);
alert(rows[0].gender);
});
});
However, I see nothing on the console and there is no alert. Why is this?
If you want the birthday and gender of an authenticated user (/me) you can just access the User Object like this:
FB.api('/me', function(response) {
console.log(response.birthday);
console.log(response.gender);
alert(response.birthday);
alert(response.gender);
});
If you want the birthday and gender to come from the user table you can't use the "gender" field because it doesn't exist. Use "sex" instead.
FB.api('/me', function(response) {
var query = FB.Data.query('select birthday, sex from user where uid={0}', response.id);
query.wait(function(rows) {
console.log(rows[0].birthday);
console.log(rows[0].gender);
alert(rows[0].birthday);
alert(rows[0].sex);
});
});
You received no response because you were trying to access a field that doesn't exist.
精彩评论