How do I add query parameters to a GetMethod (using Java commons-httpclient)?

前端 未结 3 764
傲寒
傲寒 2020-12-08 19:14

Using Apache\'s commons-httpclient for Java, what\'s the best way to add query parameters to a GetMethod instance? If I\'m using PostMethod, it\'s very straightforward:

3条回答
  •  情深已故
    2020-12-08 20:10

    Try it this way:

        URIBuilder builder = new URIBuilder("https://graph.facebook.com/oauth/access_token")
                .addParameter("client_id", application.getKey())
                .addParameter("client_secret", application.getSecret())
                .addParameter("redirect_uri", callbackURL)
                .addParameter("code", code);
    
        HttpPost method = new HttpPost(builder.build());
    

提交回复
热议问题