FB.Data.query 以及在哪里可以找到 Facebook 数据库方案?

发布于 2024-12-14 16:07:36 字数 1609 浏览 3 评论 0原文

您好,我们已经实现了以下代码

INIT 块 (WORKS)

FB.init({
    appId: 'apiID',
    status: true, // check login status
    cookie: true, // enable cookies to allow the server to access the session
    oauth: true,  // enable OAuth 2.0
    xfbml: true,   // parse XFBML
    frictionlessRequests: true
});

LOGIN 块 (WORKS)

FB.login(function(response) {
    if (response.authResponse) {
      console.log('User logged and fully authorize the app.');

    } else {
      console.log('User cancelled login or did not fully authorize.');
    }
  }, {scope: 'email,user_location,friends_location'});

DATA RETRIEVE 块 (DON'T WORK)

var friends = FB.Data.query('SELECT uid, name, location FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me() ORDER BY rand() LIMIT 15) AND has_added_app=0');

FB.Data.waitOn([friends], function() {
  FB.Array.forEach(friends.value, function(row) {
      console.log(row);
  });
});

最后“SELECT uid, name FROM user ...”不会出现问题。

有人知道 facebook 的“user”和“friend”表的数据库方案吗?可以通过“FB.Data.query”访问其他表?

谢谢你!

编辑

正确的数据检索块(工作

var friends = FB.Data.query('SELECT uid, name, hometown_location, current_location FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me() ORDER BY rand() LIMIT 15) AND has_added_app=0');

FB.Data.waitOn([friends], function() {
  FB.Array.forEach(friends.value, function(row) {
      console.log(row);
  });
});

Hi we've implemented the following code

INIT block (WORKS)

FB.init({
    appId: 'apiID',
    status: true, // check login status
    cookie: true, // enable cookies to allow the server to access the session
    oauth: true,  // enable OAuth 2.0
    xfbml: true,   // parse XFBML
    frictionlessRequests: true
});

LOGIN block (WORKS)

FB.login(function(response) {
    if (response.authResponse) {
      console.log('User logged and fully authorize the app.');

    } else {
      console.log('User cancelled login or did not fully authorize.');
    }
  }, {scope: 'email,user_location,friends_location'});

DATA RETRIEVE block (DON'T WORK)

var friends = FB.Data.query('SELECT uid, name, location FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me() ORDER BY rand() LIMIT 15) AND has_added_app=0');

FB.Data.waitOn([friends], function() {
  FB.Array.forEach(friends.value, function(row) {
      console.log(row);
  });
});

The last problem does not occur for "SELECT uid, name FROM user ...".

Does anyone get an idea of the DB scheme of the facebook's "user" and "friend" tables? Other tables which can be accessed by "FB.Data.query"?

Thank you!

EDIT

CORRECT DATA RETRIEVE block (WORKs)

var friends = FB.Data.query('SELECT uid, name, hometown_location, current_location FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me() ORDER BY rand() LIMIT 15) AND has_added_app=0');

FB.Data.waitOn([friends], function() {
  FB.Array.forEach(friends.value, function(row) {
      console.log(row);
  });
});

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

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

发布评论

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

评论(1

萌︼了一个春 2024-12-21 16:07:39

Facebook 查询语言 (FQL) 的规范可用于 Facebook 的其余部分开发人员文档,包括 用户friend 表。

The specification for the Facebook Query Language (FQL) is available with the rest of the Facebook developer documentation, including schemas for the user and friend tables.

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