【发布时间】:2015-07-31 20:16:35
【问题描述】:
我正在尝试使用 Python 的 HTTPSConnection 从我的 Twitter 用户流中读取数据。我可以成功连接并授权到 Twitter 的 API,但是,当我从网站发推文时,没有其他内容被推送到流中。我的代码如下。
import http.client
#Authorization headers cut
authheaders = """OAuth oauth_consumer_key="<snip>", oauth_nonce="<snip>", oauth_signature="<snip>", oauth_signature_method="<snip>", oauth_timestamp="<snip>", oauth_token="<snip>", oauth_version="1.0" """
conn = http.client.HTTPSConnection("userstream.twitter.com:443")
conn.putrequest("GET", "/1.1/user.json")
conn.putheader("Authorization", authheaders)
conn.endheaders()
resp = conn.getresponse()
print("HTTP " + str(resp.status))
while True:
buff = resp.read(8192)
if buff != b'':
print(buff)
【问题讨论】:
标签: python twitter twitter-oauth