Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Http 如何使用Reddit';什么是API?_Http_Curl_Http Post_Reddit - Fatal编程技术网

Http 如何使用Reddit';什么是API?

Http 如何使用Reddit';什么是API?,http,curl,http-post,reddit,Http,Curl,Http Post,Reddit,我试图通过使用Reddit API页面上列出的访问Reddit用户的帐户 我试过这个: curl -i -X POST -d '{"user":"myusername", "passwd":"mypassword", "rem":"true" }' http://www.reddit.com/api/login 但上面说的密码是错误的(我用相同的凭据登录了该网站,所以我不知道出了什么问题): 然而,这是可行的: curl -i -c Cookie.txt -d '{"user":"myuser

我试图通过使用Reddit API页面上列出的访问Reddit用户的帐户

我试过这个:

curl -i -X POST -d '{"user":"myusername", "passwd":"mypassword", "rem":"true" }' http://www.reddit.com/api/login
但上面说的密码是错误的(我用相同的凭据登录了该网站,所以我不知道出了什么问题):

然而,这是可行的:

curl -i -c Cookie.txt -d '{"user":"myusername", "passwd":"mypassword" , "rem":"true"}' http://www.reddit.com/api/login
收益率:

{
     "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", []]]
}
这也适用于:

curl -b Cookie.txt http://www.reddit.com/api/me.json
问题:

  • 有人知道如何使用RedditAPI登录Reddit吗

  • 是否有更简单的方法通过HTTP Post传递凭据以正确登录

  • 为什么在我的初始卷曲中显示无效密码


    • 以下是如何使用curl登录reddit的正确示例:

      curl -duser=USERNAME -dpasswd=PASSWORD -dapi_type=json https://ssl.reddit.com/api/login
      
      通过传递
      api\u type=json
      可以获得有意义的json输出,而不是特定于reddit的基于jquery的输出

      {"json": {"errors": [],
                "data": {"modhash": "<REMOVED>",
                         "cookie": "<REMOVED>"}
               }
      }
      
      {“json”:{“errors”:[],
      “数据”:{“modhash”:”,
      “cookie”:“}
      }
      }
      
      请注意,reddit还正确使用set cookie头,以便正确的http客户机/库将利用会话进行后续请求


      您的示例不起作用,因为您没有正确发送表单参数。你认为可能有效的例子,事实上没有。由于登录次数太多,您收到了速率限制响应。

      谢谢bboe!这个curl命令更好,因为它返回modhash。
      {"json": {"errors": [],
                "data": {"modhash": "<REMOVED>",
                         "cookie": "<REMOVED>"}
               }
      }