我正在尝试使用python oauth2来获取参与数据,因为我有enterprise account
用于Twitter。
我可以使用以下端点https://api.twitter.com/1.1/statuses/home_timeline.json
但是现在我正在尝试使用参与API,具有相同的访问详细信息,它给出的错误为{u'errors': [u'Your account could not be authenticated. Reason: Unknown Authorization Type']}
以下是该代码正在使用的:
def engagement_api(url, consumer_key, consumer_secret_key,access_key,access_secret_key, http_method="POST",http_headers={'Content-type': 'application/json'}):#def oauth_req(url, key, secret, http_method="GET", post_body=””, http_headers=None):
consumer = oauth2.Consumer(key=consumer_key, secret=consumer_secret_key)
token = oauth2.Token(key=access_key, secret=access_secret_key)
client = oauth2.Client(consumer, token)
resp, content = client.request( url, method=http_method,headers=http_headers,body=urllib.urlencode({'status': params}))
return content
if __name__ == '__main__':
engagements = engagement_api('https://data-api.twitter.com/insights/engagement/totals', consumer_key, consumer_secret_key,access_key,access_secret_key)
我正在尝试使用端点https://data-api.twitter.com/insights/engagement/totals
。当我进行搜索时,我的脑海中充满了疑问
你能请人帮我吗?