简体   繁体   中英

Is there a way to access facebook events using graphapi

I have code to look up events but keep getting an error:

File "facebook_events.py", line 8, in events = graph.request('/search?q=Poetry&type=event') File "/Users/teomeyerhoff/Desktop/projects/jakecongress/facebookenv/lib/python3.7/site-packages/facebook/ init .py", line 313, in request raise GraphAPIError(result) facebook.GraphAPIError: (#33) This object does not exist or does not support this action.

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

    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()

Thank you for the help.

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

Yes, that is the case.


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

Also mentioned in the accompanying blog 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM