Pac*_*ver 4 curl http reddit http-post
我试图通过使用其API页面上列出的Reddit API - POST登录端点来访问我的Reddit用户帐户.
我试过这个:
curl -i -X POST -d '{"user":"myusername", "passwd":"mypassword", "rem":"true" }' http://www.reddit.com/api/login
Run Code Online (Sandbox Code Playgroud)
但它说错误的密码(我使用相同的凭据登录到网站,所以我不知道什么是错的):
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
{
"jquery":
[[0, 1, "call", ["body"]], [1, 2, "attr", "find"],
[2, 3, "call", [".status"]], [3, 4, "attr", "hide"],
[4, 5, "call", []], [5, 6, "attr", "html"],
[6, 7, "call", [""]], [7, 8, "attr", "end"],
[8, 9, "call", []], [0, 10, "attr", "find"],
[10, 11, "call", [".error.WRONG_PASSWORD.field-passwd"]],
[11, 12, "attr", "show"], [12, 13, "call", []],
[13, 14, "attr", "text"], [14, 15, "call", ["invalid password"]],
[15, 16, "attr", "end"], [16, 17, "call", []]]
}
Run Code Online (Sandbox Code Playgroud)
但是,这有效:
curl -i -c Cookie.txt -d '{"user":"myusername", "passwd":"mypassword" , "rem":"true"}' http://www.reddit.com/api/login
Run Code Online (Sandbox Code Playgroud)
产量:
{
"jquery":
[[0, 1, "call", ["body"]],
[1, 2, "attr", "find"],
[2, 3, "call", [".status"]],
[3, 4, "attr", "hide"],
[4, 5, "call", []],
[5, 6, "attr", "html"],
[6, 7, "call", [""]],
[7, 8, "attr", "end"],
[8, 9, "call", []],
[0, 10, "attr", "find"],
[10, 11, "call", [".error.RATELIMIT.field-vdelay"]],
[11, 12, "attr", "show"],
[12, 13, "call", []],
[13, 14, "attr", "text"],
[14, 15, "call",
["you are doing that too much. try again in 4 minutes."]],
[15, 16, "attr", "end"], [16, 17, "call", []]]
}
Run Code Online (Sandbox Code Playgroud)
这也有效:
curl -b Cookie.txt http://www.reddit.com/api/me.json
Run Code Online (Sandbox Code Playgroud)
问题:
有谁知道如何使用Reddit API登录Reddit?
是否有更简单的方法通过HTTP Post传递凭据以正确登录?
为什么说我的初始卷曲无效密码?
bbo*_*boe 14
以下是如何使用curl登录reddit的正确示例:
curl -duser=USERNAME -dpasswd=PASSWORD -dapi_type=json https://ssl.reddit.com/api/login
Run Code Online (Sandbox Code Playgroud)
通过传递,api_type=json您获得有意义的json输出,而不是基于reddit特定的基于jquery的输出.
{"json": {"errors": [],
"data": {"modhash": "<REMOVED>",
"cookie": "<REMOVED>"}
}
}
Run Code Online (Sandbox Code Playgroud)
请注意,reddit也正确使用set-cookie标头,以便正确的http客户端/库将利用会话进行后续请求.
您的示例无效,因为您没有正确发送表单参数.您认为可能有效的示例实际上没有.由于未能登录太多次,您收到了速率限制响应.
| 归档时间: |
|
| 查看次数: |
7786 次 |
| 最近记录: |