Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
3,346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. URL obj = new URL("https://account.mojang.com/login");
  2. HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
  3. con.setRequestMethod("POST");
  4. con.setRequestProperty("Host", "account.mojang.com");
  5. con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
  6. con.setRequestProperty("Content-Length", Integer.toString(postPARAMS.length()));
  7. //System.out.println(Integer.toString(postPARAMS.length()));
  8. //con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0");
  9. //con.setRequestProperty("Connection", "keep-alive");
  10. //con.setRequestProperty("Accept-Encoding", "gzip, deflate");
  11. con.setRequestProperty("Accept", "*/*");
  12.  
  13. // For POST only - START
  14. con.setDoOutput(true);
  15. OutputStream os = con.getOutputStream();
  16. os.write(postPARAMS.getBytes());
  17. os.flush();
  18. os.close();
  19. // For POST only - END
  20.  
  21. System.out.println("POST Response Code :: " + con.getResponseCode());
  22.  
  23. final HttpClient client = HttpClientBuilder.create().build();
  24. final HttpPost loginPost = new HttpPost("https://account.mojang.com/login");
  25. loginPost.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36");
  26. final List<NameValuePair> loginParams = new ArrayList<NameValuePair>();
  27. loginParams.add(new BasicNameValuePair("username", email));
  28. loginParams.add(new BasicNameValuePair("password", password));
  29. loginPost.setEntity(new UrlEncodedFormEntity(loginParams));
  30. client.execute(loginPost);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement