我有用于查找事件的代码,但始终出现错误:
文件“ facebook_events.py”,第8行,在 事件= graph.request('/ search?q = Poetry&type = event') 请求中的文件“ /Users/teomeyerhoff/Desktop/projects/jakecongress/facebookenv/lib/python3.7/site-packages/facebook/init.py” 提高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()
谢谢您的帮助。
答案 0 :(得分:0)
似乎我无法再使用查询字符串“ / 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
已弃用:
- 支持使用搜索来查找页面,组,事件,用户。