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
而不是返回字符串
{
"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