在我的twitter回调处理程序中,我似乎无法发出httplib POST请求,因为它会抛出一个不相关的401 Token Invalid Expired错误 . 我正在使用Google App Engine并尝试了urlfetch功能 .
`headers = {“Content-type”:“application / x-www-form-urlencoded”,“Accept”:“text / plain”} conn = httplib.HTTPConnection(create_url)conn.request(“POST”,“” ,form_data,headers)response = conn.getresponse()if response.status == 500:#do stuff
匹配错误日志:Twitter API返回401(未授权),无效/已过期要肯
1 回答
解决方案是使用Requests库来获取POST请求 . 由于某些未知原因,httplib或urlfetch在Google App Engine上的twittercallback endpoints 中都不起作用 .