我想为Pocket
(以前读过)开发一个python客户端。
我正在研究它的 OAuth 过程。并被困在这里。如何执行此请求并获得响应?
POST /v3/oauth/request HTTP/1.1
Host: getpocket.com
Content-Type: application/json; charset=UTF-8
X-Accept: application/json
{"consumer_key":"1234-abcd1234abcd1234abcd1234",
"redirect_uri":"pocketapp1234:authorizationFinished"}
我是 python 新手。这是我试过的。但我无法得到我想要的回应。
#!/usr/bin/env python
import urllib2
import json
def main():
# Whatever structure you need to send goes here:
jdata = json.dumps({"consumer_key":"1234-abcd1234abcd1234abcd1234", "redirect_uri":"pocketapp1234:authorizationFinished"})
response = urllib2.urlopen("http://getpocket.com", jdata)
the_page = response.read()
print the_page
if __name__ == '__main__':
main()