GraphAPIError:必须使用活动访问令牌来查询有关当前用户的信息

时间:2016-09-25 10:07:11

标签: python facebook facebook-graph-api

在Facebook GraphAPI上,使用Python SDK,我试图向用户发送通知。我收到错误:

GraphAPIError: An active access token must be used to query information about the current user  

我的Python代码是:

graph = facebook.GraphAPI(access_token=TOKENS["app_token"])
graph.put_object(parent_object='me', connection_name='notifications', template='Tell us how you like the app!', href='https://www.google.com')

1 个答案:

答案 0 :(得分:0)

解决方案:

graph = facebook.GraphAPI(access_token=TOKENS["user_token"]) 
user_info= graph.get_object(id='me', fields='id')  
graph = facebook.GraphAPI(access_token=TOKENS["app_token"])
graph.put_object(parent_object= user_info['id'], connection_name='notifications', template='Tell us how you like the app!', href='https://www.google.com')