使用 FB.data.query 没有得到任何响应

发布于 2024-11-03 07:15:42 字数 534 浏览 0 评论 0原文

我试图通过以下方式获取用户性别和出生日期:

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

但是,我在控制台上看不到任何内容,也没有任何警报。这是为什么呢?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

゛清羽墨安 2024-11-10 07:15:42

如果您想要经过身份验证的用户(/me)的生日和性别,您可以像这样访问用户对象:

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

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

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

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文