使用facebook fql,我如何找到一所学校在哪里



[注:前两个答案,包括我写的那个,还没有处理"可选的" fql。multiquery问题。)

当我使用facebook的fql时,我可以得到我或朋友上过的学校列表。具体来说,我能查到学校的名字,还有它的facebook账号。然而,我不知道如何查询这些学校的更深入的信息。

具体来说,我想知道学校在哪里。但是,我不知道这些学校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。多查询查找信息的学校(或其他此类实体)返回在其他地方的多查询?

我建议使用批处理请求(更多信息在这里:https://developers.facebook.com/docs/reference/api/batch/)来查询基于你已经拥有的学校ID的图形。学校的位置可以在返回的默认基本信息中检索(示例如下)。

{
   "id": "6192688417",
   "name": "Stanford University",
   "picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/41571_6192688417_2310209_s.jpg",
   "link": "https://www.facebook.com/stanford",
   "likes": 203153,
   "category": "Education",
   "website": "http://www.stanford.edu",
   "username": "stanford",
   "founded": "1891",
   "location": {
      "street": "450 Serra Mall",
      "city": "Stanford",
      "state": "CA",
      "country": "United States",
      "zip": "94305",
      "latitude": 37.42895,
      "longitude": -122.1697
   },
   "public_transit": "http://transportation.stanford.edu",
   "general_info": "Located between San Francisco and San Jose in the heart of Silicon Valley, Stanford University is recognized as one of the world's leading research and teaching institutions.nnLeland and Jane Stanford founded the University to "promote the public welfare by exercising an influence on behalf of humanity and civilization." Stanford opened its doors in 1891, and more than a century later, it remains dedicated to finding solutions to the great challenges of the day and to preparing our students for leadership in today's complex world.",
   "checkins": 9938
}

并且,看起来要让fql工作,我想要查询页表。例如:

select name,location from page where page_id = 87873693141

(也就是说,我仍然试图找出如何提取列表我的教育的学校id到where子句的多查询)

最新更新