Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. String SIGNATURE = "signature"; //(This data is huge)
  2.  
  3. String url = "someUrl";
  4. URL obj = new URL(url);
  5. HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
  6.  
  7. //add reuqest header
  8. con.setRequestMethod("POST");
  9. con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
  10. con.setRequestProperty("PS-Sign",SIGNATURE);
  11.  
  12.  
  13. // Send post request
  14. con.setDoOutput(true);
  15. DataOutputStream wr = new DataOutputStream(con.getOutputStream());
  16. wr.flush();
  17. wr.close();
  18.  
  19. int responseCode = con.getResponseCode();
  20.  
  21. BufferedReader in = new BufferedReader(
  22. new InputStreamReader(con.getInputStream()));
  23. String inputLine;
  24. StringBuffer response = new StringBuffer();
  25.  
  26. while ((inputLine = in.readLine()) != null) {
  27. response.append(inputLine);
  28. }
  29. in.close();
  30.  
  31. //print result
  32. System.out.println(response.toString());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement