【问题标题】:Is there a way to access facebook events using graphapi有没有办法使用图形 api 访问 facebook 事件
【发布时间】:2019-11-19 22:45:14
【问题描述】:

我有代码可以查找事件,但不断收到错误:

文件“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()

感谢您的帮助。

【问题讨论】:

    标签: python facebook-graph-api python-requests facebook-requests


    【解决方案1】:

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

    是的,就是这样。


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

    搜索 API

    您不能再将 /search 端点与以下对象类型一起使用:

    • 事件
    • 页面
    • 用户

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

    搜索 API

    已弃用:

    • 支持使用搜索查找页面、组、事件、用户。

    【讨论】:

      猜你喜欢
      • 2019-10-12
      • 2017-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-02
      • 1970-01-01
      相关资源
      最近更新 更多