使用FB.data.query没有得到任何回应 [英] using FB.data.query not getting any response back

查看:148
本文介绍了使用FB.data.query没有得到任何回应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过以下方式获取用户的性别和生日:

  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);
});
});

但是,我在控制台上看不到任何信息,没有警报。为什么是这样?

解决方案

如果您想要验证用户(/ me)的生日和性别,您只需访问用户对象像这样:

  FB.api('/ me',function(response){
console.log response.birthday);
console.log(response.gender);
alert(response.birthday);
alert(response.gender);
});

如果您希望生日和性别来自用户表,您不能使用性别因为它不存在。使用sex代替。

  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 [ .sex);
});
});

您没有收到任何回复,因为您尝试访问不存在的字段。 >

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.

这篇关于使用FB.data.query没有得到任何回应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆