Advertisement
Guest User

Untitled

a guest
Apr 9th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. String postData = String.format("username=%s&password=%s",
  2. URLEncoder.encode(username, "UTF-8"),
  3. URLEncoder.encode(password, "UTF-8"));
  4.  
  5. URL url = new URL("http://example.com/login.php");
  6. HttpURLConnection connection =
  7. (HttpURLConnection) url.openConnection(createTorProxy());
  8. connection.setRequestMethod("POST");
  9. connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
  10. connection.setRequestProperty("Content-Length", String.valueOf(postData.length()));
  11. connection.setDoOutput(true);
  12.  
  13. OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
  14. writer.write(postData);
  15. writer.flush();
  16. writer.close();
  17.  
  18. Log.d(TAG, String.format("Login result: %d", connection.getResponseCode()));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement