1

因此,我正在尝试访问 imgur API 以获取某个 reddit 子图库中的图像列表。这是我迄今为止尝试过的:

>>> header = {'client_id': 'thisismyclientid', 'response_type': 'pin'}
>>> r = requests.get('https://api.imgur.com/oauth2/authorize', headers=header, verify=False)
>>> r.text
u'{"data":{"error":"client_id and response_type are required","request":"\\/oauth2\\/authorize","parameters":"","method":"GET"},"success":false,"status":400}'

不完全确定我做错了什么,这不是传递我的 client_id 和响应类型的正确方法吗?

4

1 回答 1

2

快速查看文档会发现:

https://api.imgur.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&response_type=REQUESTED_RESPONSE_TYPE&state=APPLICATION_STATE

这些是获取参数,而不是标题。所以你必须通过字典params而不是headers.

于 2013-02-10T01:41:42.167 回答