Guest User

Untitled

a guest
Dec 25th, 2015
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.32 KB | None | 0 0
  1.  
  2. InputStream in = null;
  3. String s = "";
  4.  
  5. String api_sig = new String(Hex.encodeHex(DigestUtils.md5("api_key" + API_KEY + methodauth.getMobileSessionpassword" + PASSWORD + "username" + USERNAME + SECRET)));
  6. try {
  7. HttpURLConnection c;
  8. s = String.valueOf(isNetworkAvailable());
  9. URL url = new URL("http://ws.audioscrobbler.com/2.0/");//?method=auth.getMobileSession&api_key=" + API_KEY + "&username=" + USERNAME + "&password=" + PASSWORD + "&api_sig=" + api_sig);
  10.  
  11. c = (HttpURLConnection) url.openConnection();
  12. //c.setRequestMethod("POST");
  13. //c.setRequestProperty("method", "auth.getMobileSession" );
  14. //c.setRequestProperty("api_key", API_KEY);
  15. //c.setRequestProperty("username", USERNAME);
  16. //c.setRequestProperty("password", PASSWORD);
  17. //c.setRequestProperty("api_sig", api_sig);
  18. //c.setDoOutput(true);
  19. //c.setDoInput(true);
  20. //DataOutputStream ds = new DataOutputStream(c.getOutputStream());
  21. //ds.writeBytes(data);
  22. //ds.flush();
  23. //ds.close();
  24. c.connect();
  25. //s = String.valueOf(c.getResponseCode());
  26. in = new DataInputStream(c.getInputStream());
  27. //InputStreamReader isr = new InputStreamReader(is);
  28. //BufferedReader reader = new BufferedReader(isr);
  29. s= in.toString();
  30.  
  31.             } catch (MalformedURLException e) {
  32.                 e.printStackTrace();
  33.             } catch (IOException e) {
  34.                 return e.toString();
  35.             }
  36.             finally {
  37.                 return s;
  38.             }
Add Comment
Please, Sign In to add comment