Httpz http = new Httpz(); http.setUrl("https://api.example.com/data"); http.setMethod(Httpz.HttpMethod.GET); http.addHeader("Content-Type", "application/json"); http.addHeader("Authorization", "Bearer your_token"); http.addParam("username", "john"); http.addParam("password", "pass123"); HttpResponse httpResponse = http.execute(); int responseCode = httpResponse.getResponseCode(); String responseContent = httpResponse.getResponse(); String responseString = httpResponse.getResponse(); JSONObject responseJson = new JSONObject(httpResponse.getResponse()); String data = responseJson.getString("data"); import net.httpz.Httpz; import net.httpz.Response; Httpz http = new Httpz(); http.setUrl("https://api.example.com/data"); http.setMethod(Httpz.HttpMethod.GET); http.addHeader("Content-Type", "application/json"); http.addHeader("Authorization", "Bearer your_token"); http.addParam("username", "john"); http.addParam("password", "pass123"); Response httpResponse = http.execute(); int responseCode = httpResponse.getResponseCode(); String responseContent = httpResponse.getResponse(); System.out.println("Response Code: " + responseCode); System.out.println("Response Content: " + responseContent);


上一篇:
下一篇:
切换中文