Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/358.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
Java 请求访问令牌时,reddit api返回429错误_Java_Reddit - Fatal编程技术网

Java 请求访问令牌时,reddit api返回429错误

Java 请求访问令牌时,reddit api返回429错误,java,reddit,Java,Reddit,当我试图检索访问令牌getting 429:to Many Requests error时,我已经按照链接--> 错误的原因可能是什么。这是我的代码 public static void main (String[] args) throws Exception { String url3 ="https://www.reddit.com/api/v1/access_token?"; OAuthRequest get_info_request = new OAuthReque

当我试图检索访问令牌getting 429:to Many Requests error时,我已经按照链接-->

错误的原因可能是什么。这是我的代码

public static void main (String[] args) throws Exception
{ 
    String url3 ="https://www.reddit.com/api/v1/access_token?";

    OAuthRequest get_info_request = new OAuthRequest(Verb.POST, url3);
    get_info_request.setCharset("UTF-8");
    get_info_request.addBodyParameter("grant_type", "authorization_code");
    get_info_request.addBodyParameter("redirect_uri", "xxxxxxxxxx");
    get_info_request.addBodyParameter("code", "xxxxxxxxx");
    get_info_request.addBodyParameter("USER_AGENT", "desktop:net.dean.ayati:v0.9.0 (by /u/ayati)");
    System.out.println(get_info_request.getCompleteUrl()+get_info_request.getBodyContents());
    Response json_response = get_info_request.send();
    System.out.println(json_response.getBody());
    JSONObject jsonResp = new JSONObject(json_response.getBody());
    System.out.println("is" + jsonResp);
}

虽然HTTP头不区分大小写,但仍有用户\u代理拼写错误

它在里面用了一个“-”not“

尝试:


看看这是否有效。

我已经尝试过了,但仍然收到了相同的错误。还有其他建议吗?您的响应中是否有任何X_Ratelimit_u*头表明您超出了限制?没有,每次我都收到这种类型的响应:{“消息”:“请求太多”,“错误”:429}。
get_info_request.addBodyParameter("User-Agent", "desktop:net.dean.ayati:v0.9.0 (by /u/ayati)");