有没有办法使用图形 API 访问 facebook 事件

Is there a way to access facebook events using graphapi

我有查找事件的代码,但一直收到错误消息:

文件 "facebook_events.py",第 8 行,位于 events = graph.request('/search?q=Poetry&type=event') 请求中的文件“/Users/teomeyerhoff/Desktop/projects/jakecongress/facebookenv/lib/python3.7/site-packages/facebook/init.py”,第 313 行 引发 GraphAPIError(结果) facebook.GraphAPIError: (#33) 此对象不存在或不支持此操作。

Facebook api 有什么变化吗?看起来我无法再使用查询字符串访问事件:'/search?q=Poetry&type=event' 作为图形请求。

    import urllib3
    import facebook
    import requests

    token = "EA......" //not actual token

    graph = facebook.GraphAPI(access_token=token, version = "2.8")
    events = graph.request('/search?q=Poetry&type=event')

    print(events)

    eventList = events['data']
    eventid = eventList[1]['id']

    event1 = graph.get_object(id=eventid, fields='attending_count, can_guests_invite, \
                              category, cover, declined_count, description, \
                              end_time, guest_list_enabled, interested_count, \
                              is_canceled, is_page_owned, is_viewer_admin, \
                              maybe_count, noreply_count, owner, parent_group,\
                              place, ticket_uri, timezone, type, updated_time')

    attenderscount = event1['attending_count']
    declinerscount = event1['declined_count']
    interestedcount = event1['interested_count']
    maybecount = event1['maybe_count']
    noreplycount = event1['noreply_count']

    attenders = requests.get('https://graph.facebook.com/v2.8/"+eventid+"\
                              /attending?access_token="+token+"&limit='+str(attenderscount))

    attenders_json = attenders.json()

    admins = requests.get("https://graph.facebook.com/v2.8/"+eventid+"\
                          /admins?access_token="+token)

    admins_json = admins.json()

感谢您的帮助。

It looks as though I can no longer access events using the query string: '/search?q=Poetry&type=event' as a graph request.

是的,是这样。


https://developers.facebook.com/docs/graph-api/changelog/breaking-changes#search-4-4

Search API

You can no longer use the /search endpoint with the following object types:

  • event
  • group
  • page
  • user

在随附的博客中也提到了post、https://developers.facebook.com/blog/post/2018/04/04/facebook-api-platform-product-changes/

Search API

Deprecated:

  • Support for finding pages, groups, events, users using search.