I want to develop a python client for Pocket (formerly read it later).
I am studying the OAuth process of it. And be stuck here. How can I perform this request and get the response?
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"}
I am new to python. This is I have tried. But I can not get the response I want.
#!/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()
Use the
requestslibrary for this sort of work. (EDITED)