我可以从我的 Twython 回调处理程序发出一个 httplib POST 请求 returns 状态 500 吗?
Can I make an httplib POST request that returns a status of 500 from my Twython callback handler?
在我的 Twitter 回调处理程序中,我似乎无法发出 httplib POST 请求,因为它会抛出不相关的 401 令牌无效过期错误。我正在使用 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(未经授权),无效/过期 To ken
解决方案是对 POST 请求使用 Requests 库。由于某些未知原因,httplib 或 urlfetch 都无法在 Google App Engine 上的 twittercallback 端点中工作。
在我的 Twitter 回调处理程序中,我似乎无法发出 httplib POST 请求,因为它会抛出不相关的 401 令牌无效过期错误。我正在使用 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(未经授权),无效/过期 To ken
解决方案是对 POST 请求使用 Requests 库。由于某些未知原因,httplib 或 urlfetch 都无法在 Google App Engine 上的 twittercallback 端点中工作。