How to login using Reddit's API?

℡╲_俬逩灬. 提交于 2019-12-03 16:24:34

The following is a proper example of how to use curl to login to reddit:

curl -duser=USERNAME -dpasswd=PASSWORD -dapi_type=json https://ssl.reddit.com/api/login

By passing api_type=json you get meaningful json output rather than reddit-specific jquery based output.

{"json": {"errors": [],
          "data": {"modhash": "<REMOVED>",
                   "cookie": "<REMOVED>"}
         }
}

Note that reddit also properly uses the set-cookie header so that a proper http client / library will take advantage of the session for subsequent requests.

Your example did not work because you were not properly sending the form parameters. The example that you thought might have worked, in-fact did not. You were receiving a rate-limit response for failing to login too many times.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!