2016-09-25 56 views
0

在Facebook GraphAPI上,使用Python SDK,我試圖向用戶發送通知。我收到的錯誤:GraphAPIError:必須使用活動訪問令牌來查詢有關當前用戶的信息

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

不能使用'/ me'與應用程序的訪問令牌。您需要使用應用程序範圍的用戶標識。 – CBroe

回答

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') 
相關問題