Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static String checkCredentials(List<String> credentials) {
- Log.d(TAG, "In checkCredentials");
- Log.d(TAG,"Credentials are "+credentials.toString());
- String user_name = credentials.get(0);
- Log.d(TAG, "user_name is "+user_name);
- String user_password = credentials.get(1);
- String httpsURL = "https://willbeddow.com/auth.cgi";
- String charset = "UTF-8";
- String param1 = user_name;
- String param2 = user_password;
- String query = "user=" + encode(user_name);
- query += "&";
- query += "password=" + encode(user_password);
- Log.d(TAG, "Finished formatting url, HttpsURL is "+httpsURL);
- try{
- URL myurl = new URL(httpsURL);
- HttpsURLConnection con = (HttpsURLConnection) myurl.openConnection();
- con.setRequestMethod("POST");
- con.setRequestProperty("Content-length", valueOf(query.length()));
- con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
- con.setDoOutput(true);
- con.setDoInput(true);
- DataOutputStream output = new DataOutputStream(con.getOutputStream());
- output.writeBytes(query);
- output.close();
- DataInputStream input = new DataInputStream(con.getInputStream());
- for (int c = input.read(); c != -1; c = input.read())
- System.out.print((char) c);
- input.close();
- Log.d(TAG, "Resp Code:"+con .getResponseCode());
- Log.d(TAG, System.out.println("Resp Message:"+ con .getResponseMessage());
- return con.getResponseMessage();
- }
- catch (Exception m){
- Log.d(TAG, "Exception "+m.toString()+" occurred. URL was: "+httpsURL.toString());
- return "Exception";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement