FB.Data.query 以及在哪里可以找到 Facebook 数据库方案?
您好,我们已经实现了以下代码
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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.