Advertisement
Guest User

Untitled

a guest
Jan 28th, 2015
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. public boolean login(String email, String pass) throws Exception{
  2. HttpsURLConnection con = (HttpsURLConnection) new URL("https://www.swagbucks.com/z/0.5352812726557298/?cmd=ac-login-post").openConnection();
  3. con.setRequestMethod("POST");
  4. con.setRequestProperty("User-Agent", agents[agentNum]);
  5. con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
  6. con.setDoOutput(true);
  7. DataOutputStream wr = new DataOutputStream(con.getOutputStream());
  8. wr.writeBytes("emailAddress=" + URLEncoder.encode(email ,"UTF-8")+ "&password=" + URLEncoder.encode(pass, "UTF-8") + "&isLoginPage=true&persist=on");
  9. BufferedReader in = new BufferedReader(
  10. new InputStreamReader(con.getInputStream()));
  11. String inputLine;
  12. StringBuffer response = new StringBuffer();
  13. while ((inputLine = in.readLine()) != null) {
  14. response.append(inputLine + "\n");
  15. }
  16. System.out.println(response);
  17. in.close();
  18. return !new String(response).contains("error");
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement