使用 facebook fql,如何找到学校在哪里?
[注意:前两个答案,包括我写的答案,尚未处理“可选”fql.multiquery 问题。]
当我使用 facebook 的 fql 时,我可以获得我就读过的学校列表,或者朋友们都参加了。具体来说,我可以得到学校的名字,以及它的facebook id。但是我不知道如何查询这些学校更深入的信息。
具体来说,我想知道这些学校位于哪里。但是,我不知道这些学校 ID 属于哪个 Facebook 图实体(或其他任何实体)。
我如何从 Facebook 找到这些学校的位置?
可选:如果可以在首先返回学校列表的同一个多重查询中完成此操作,那就更好了(这将是针对我的 id 的用户表的查询,以及针对我的 id 的用户表的另一个查询)我的朋友们)。
这是上一段中提到的可选部分的扩展版本(请注意,我尝试将其添加为一个单独的问题,但是当我让说明性数据更相关时,我发现它已经悄然消失了。所以我假设我被堆栈溢出的一些功能绊倒了,这些功能旨在消除彼此过于相似的问题,所以,相反,我们只是说这是我在上一段中的意思的澄清)
使用facebook的javascript sdk,这。失败,默默地:
FB.login(function(response){
disp('loginResponse', response);
var userQuery= FB.Data.query(
'select uid,name,education from user where uid= {0}'
, response.session.uid);
var friendlist = FB.Data.query(
'select uid2 from friend where uid1 = {0} order by rand() limit 10'
, response.session.uid);
var friends = FB.Data.query(
'select uid,name,education from user where uid in (select uid2 from {0})'
, friendlist);
var friendSchools= FB.Data.query(
'select page_id,name,location from page where page_id in (select education.school.id from {0})'
, friends);
self.queries= [userQuery, friendlist, friends, friendSchools];
FB.Data.waitOn(queries
, function() {alert(1)});
})
如果我从查询数组中删除friendSchools元素,它工作得很好,并且朋友可能由这样的对象表示:
{
uid: '...',
name: '...',
education:
[
{
school:
{
id: '115920001751600',
name: 'Burlington High School'
},
year:
{
id: '138792749476094',
name: '1978'
},
type: 'High School'
},
{
school:
{
id: '20697868961',
name: 'Boston University'
},
degree:
{
id: '188387604516411',
name: 'BS'
},
year:
{
id: '103823546338323',
name: '1982'
},
type: 'College'
}
]
}
那么,如何重构friendSchools查询中的where子句,以便该查询可以被执行?
换句话说,如何使用 fql.multiquery 查找有关多重查询中其他地方返回的学校(或其他此类实体)的信息?
[Note: the first two answers, which includes the one I wrote, do not yet deal with the "optional" fql.multiquery issue.]
When I am using facebook's fql, I can get a list of schools I have attended, or that friends have attended. Specifically, I can get the school's name, and it's facebook id. However, I do not know how to query for deeper information about these schools.
Specifically, I would like to find out where the schools were located. But, I do not know what facebook graph entity (or whatever else) those school ids are part of.
How would I find out from facebook where these schools are located?
Optional: It would be even better if this can be done in the same multiquery that returned the lists of schools in the first place (this would be a query against the user table for my id and another query against the user table for some ids of my friends).
Here's an expanded version of the optional part mentioned in the above paragraph (note that I tried adding this as a separate question, but when I went in make the illustrative data more relevant, I saw that it had silently vanished. So I am assuming I tripped over some feature of stack overflow designed to weed out questions which are too similar to each other. So, instead, let's just say that this is a clarification of what I meant, in the above paragraph)
Using facebook's javascript sdk, this fails, silently:
FB.login(function(response){
disp('loginResponse', response);
var userQuery= FB.Data.query(
'select uid,name,education from user where uid= {0}'
, response.session.uid);
var friendlist = FB.Data.query(
'select uid2 from friend where uid1 = {0} order by rand() limit 10'
, response.session.uid);
var friends = FB.Data.query(
'select uid,name,education from user where uid in (select uid2 from {0})'
, friendlist);
var friendSchools= FB.Data.query(
'select page_id,name,location from page where page_id in (select education.school.id from {0})'
, friends);
self.queries= [userQuery, friendlist, friends, friendSchools];
FB.Data.waitOn(queries
, function() {alert(1)});
})
If I remove the friendSchools element from the queries array, it works just fine, and a friend might be represented by an object like this:
{
uid: '...',
name: '...',
education:
[
{
school:
{
id: '115920001751600',
name: 'Burlington High School'
},
year:
{
id: '138792749476094',
name: '1978'
},
type: 'High School'
},
{
school:
{
id: '20697868961',
name: 'Boston University'
},
degree:
{
id: '188387604516411',
name: 'BS'
},
year:
{
id: '103823546338323',
name: '1982'
},
type: 'College'
}
]
}
So, how do I restructure the where clause in the friendSchools query so that that query can be performed?
In other words, how can I use fql.multiquery to find information about schools (or other such entities) returned elsewhere in the multiquery?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议使用批量请求(更多信息请参见:https://developers.facebook.com /docs/reference/api/batch/)根据您已有的学校 ID 查询图表。可以在返回的默认基本信息中检索学校的位置(示例如下)。
I would suggest using batch requests (more information here: https://developers.facebook.com/docs/reference/api/batch/) to query the graph based on the schools ID you already have. The location of the school can be retrieved in it's default basic information returned (example below).
而且,看起来让 fql 工作我想查询页表。例如:(
也就是说,我仍在尝试找出如何将我的教育学校 ID 列表提取到多查询的 where 子句中。)
And, it looks like to get fql to work I want to be querying the page table. For example:
(That said, I'm still trying to figure out how to extract the list my education's school ids into the where clause for a multi-query.)