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是其中的第一個。 –