在Facebook Graph API上获取关于场地ID /事件的eventing_count活动

时间:2015-01-20 22:07:06

标签: facebook-graph-api

我正在尝试在facebook图形API上获取attending_count。我知道要通过/event-id?fields=attending_count我可以获得这些信息,但是当在场地/venue-id/events?fields=attending_count内尝试这个时,这不会被显示。

以下是我正在尝试的内容:

https://graph.facebook.com/v2.2/217733628398158/events?fields=id,cover,name,venue,description,ticket_uri,start_time,attending_count&access_token=....

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

Event对象上没有attending_count字段,但有一个attending边缘:

为什么要在地点的网页ID上获取attending_count?这没有多大意义。

您可以使用summary获取此类参与者的绝对数量

/217733628398158/events?fields=id,cover,name,venue,description,ticket_uri,start_time,attending.summary(true).limit(1)

为了减少Graph API返回的数据量,我添加了.limit(1),每个事件只返回一个与会者,但无论如何都要生成摘要计数。如果您需要整个列表,请删除limit参数。

所以,它返回

{
  "data": [
    {
      "id": "326299167565639", 
      "cover": {
        "cover_id": "839491946113340", 
        "source": "https://scontent-a.xx.fbcdn.net/hphotos-xpa1/t31.0-8/s720x720/10547740_839491946113340_540194689313513221_o.jpg", 
        "offset_y": 28, 
        "offset_x": 0
      }, 
      "name": "Feeling This • Histórias de verão", 
      "venue": {
        "name": "Lima e Silva, 1037, Porto Alegre"
      }, 
      "description": "ARE YOU FEELING THIS?\nÉ a nostalgia da estação quente que tá batendo!\n\nFaça aqui a sua história de verão.\nThese are the best days of our lives!\n\n-\n\nIngressos:\nR$15 com Feeling Cup!*\nR$20 na lista* <http://goo.gl/1I9vV8>\nR$25 na hora\n\n* Lista encerra às 20h do dia da festa. \n* Válido para entrada até 00h\n\n\nQuer comemorar seu aniversário na FEELING THIS? Entre em contato através do e-mail cucko@cucko.com.br para saber das vantagens.", 
      "ticket_uri": "https://www.facebook.com/ajax/events/ticket.php?event_id=326299167565639&source=12&ext=1421830108&hash=ATX8w7CCSBVhKO6G", 
      "start_time": "2015-02-04T22:00:00-0200", 
      "attending": {
        "data": [
          {
            "name": "Foo Pretenders", 
            "rsvp_status": "attending", 
            "id": "1395261354109384"
          }
        ], 
        "paging": {
          "cursors": {
            "after": "TVRBd01EQTROelkxT1RnMk9UYzBPakUwTWpNd09UUTBNREE2TVRZMU1EZzBPRGsyT0RRNE5UZ3g=", 
            "before": "TVRBd01EQTROelkxT1RnMk9UYzBPakUwTWpNd09UUTBNREE2TVRZMU1EZzBPRGsyT0RRNE5UZ3g="
          }, 
          "next": "https://graph.facebook.com/v2.2/326299167565639/attending?summary=true&limit=1&after=TVRBd01EQTROelkxT1RnMk9UYzBPakUwTWpNd09UUTBNREE2TVRZMU1EZzBPRGsyT0RRNE5UZ3g="
        }, 
        "summary": {
          "count": 634
        }
      }
    },
    ....
]

有634人参加特定活动。