更新时间:2021-11-21 10:06:18
/api/me.json
路线仅接受GET请求:
The /api/me.json
route only accepts GET requests:
s = client.get('http://www.reddit.com/api/me.json')
该端点没有POST路由,因此您将获得404.
There is no POST route for that endpoint, so you'll get a 404 for that.
此外,如果需要将modhash
传递给服务器,请在POST请求中传递的数据中进行;设置client.modhash
不会不是,然后将该参数传递给服务器.您从me.json
GET响应中检索 modhash:
Also, if you need to pass modhash
to the server, do so in the data passed in the POST request; setting client.modhash
does not then pass that parameter to the server. You retrieve the modhash from your me.json
GET response:
r = client.get('http://www.reddit.com/api/me.json')
modhash = r.json()['modhash']
请注意,来自requests
的响应如何具有.json()
方法,无需自己使用json
模块.
Note how the response from requests
has a .json()
method, there is no need to use the json
module yourself.
然后在POST请求数据中使用modhash
:
You then use the modhash
in POST request data:
client.post('http://www.reddit.com/api/updateapp', {'modhash': modhash, 'about_url': '...', ...})