0
我正在嘗試從他們的API中爲數據科學工作推出requests.get()
。我正在嘗試關注文檔,但對我有點困惑。這是我的代碼...Requests.get Twitter API錯誤身份驗證
import requests
import oauth2 as o
consumer_key = 'sdfgsdfgsdfgsdfgsdfg'
consumer_secrete = 'sadfasdfgasdfasdfasdfasdfasdf'
consumer = o.Consumer(key=consumer_key, secret=consumer_secrete)
access_token = 'asdfasdfsadfasdfasdf'
access_token_secret = 'asdfasdfasdfasdfasdf'
acc_token = o.Token(key=access_token, secret=access_token_secret)
client = o.Client(consumer, acc_token)
base_url = 'https://api.twitter.com/1.1/search/tweets.json?q=%22I%20want%20to%20take%20my%20life%20away%22%20near%3A%22Grove%20South%22%20within%3A1500mi&src=typd'
data = requests.get(base_url, client)
print(data)
我收到了400 Response
。 Python中有很多模塊和庫很難知道它是否與Python 3兼容,如果它與API兼容。這有點令人困惑。有誰知道我是否可以用requests
和oauth2
來做到這一點,或者我需要改變我的方法?
爲什麼不使用一個實際的Python Twitter的API包裝?請求肯定是Python 3兼容的。 – jonrsharpe