1
from oauth_hook import OAuthHook
import requests, json
OAuthHook.consumer_key = "KEYHERE"
OAuthHook.consumer_secret = "SECRET HERE"
oauth_hook = OAuthHook("TOKEN_KEY_HERE", "TOKEN_SECRET_HERE", header_auth=True)
headers = {'content-type': 'application/json'}
client = requests.session(hooks={'pre_request': oauth_hook}, headers=headers)
payload = {"title":"album title"}
r = client.post("http://api.imgur.com/2/account/albums.json",payload)
print r.text
这应该创建一个相册的标题album title
则返回的字符串是如何代替要求张贴到imgur
{
"albums": {
"id": "IMGURID",
"title": "",
"description": "",
"privacy": "public",
"cover": "",
"order": 0,
"layout": "blog",
"datetime": "2012-12-05 15:48:21",
"link": "IMGUR LINK",
"anonymous_link": "ANONYLINK"
}
}
没有人有使用设定请求专辑标题的解决方案?
这里是对imgur API文档http://api.imgur.com/resources_auth
编码的有效载荷只是URL没有任何区别,它应该工作,但它并不 –
@lab_notes:有可能是*其他*问题也是,但不正确编码JSON是其中的第一个。 –