Facebook图形API:嵌套查询

时间:2016-02-15 12:06:22

标签: facebook-graph-api

我正在尝试对facebook图形API执行嵌套查询,以通过同一个调用来检索页面数据和页面喜欢(即页面喜欢的页面)。

以下是页面数据的查询:

https://graph.facebook.com/v2.5/nytimes?fields=name,about,likes,website,description,category,cover,emails,general_info,username,talking_about_count

它返回输出1:

{
   "name": "The New York Times",
   "about": "Welcome to The New York Times on Facebook - a hub for conversation about news and ideas. Like our page and connect with Times journalists and readers. ",
   "likes": 10724374,
   "website": "www.nytimes.com www.twitter.com/nytimes www.youtube.com/nytimes",
   "category": "Media/News/Publishing",
   "cover": {
      "cover_id": "10150582560169999",
      "offset_x": 0,
      "offset_y": 0,
      "source": "https://scontent.xx.fbcdn.net/hphotos-xaf1/t31.0-8/s720x720/11262391_10150582560169999_4778921193093539141_o.jpg",
      "id": "10150582560169999"
   },
   "emails": [
      "help\u0040nytimes.com"
   ],
   "username": "nytimes",
   "talking_about_count": 852257,
   "id": "5281959998"
}

以下是页面赞的查询:

https://graph.facebook.com/v2.5/nytimes/likes

它返回输出2:

{
   "data": [
      {
         "name": "Sheri Fink",
         "id": "161972884003991"
      },
      {
         "name": "The New York Times Books",
         "id": "1002391179791389"
      },
      {
         "name": "The New York Times Styles",
         "id": "993603507345855"
      },
      ...

有没有办法在使用nested requests的唯一调用中执行这两个查询以使输出2嵌套在输出1中?

1 个答案:

答案 0 :(得分:2)

我很遗憾不认为这是可能的,因为这是图谱API中的歧义。几个月前我打开了一个关于这个的bug,看看