android Login to website -
hi trying login njit site using httpost. reason keep getting rejected if use correct username , password. kind new php searched problem website looking cookie. can me this. thank in advance
public void postlogindata() { // create new httpclient , post header httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("https://cp4.njit.edu/cp/home/login"); try { // add user name , password edittext uname = (edittext)findviewbyid(r.id.txt_username); string username = uname.gettext().tostring(); edittext pword = (edittext)findviewbyid(r.id.txt_password); string password = pword.gettext().tostring(); list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(3); namevaluepairs.add(new basicnamevaluepair("user", username)); namevaluepairs.add(new basicnamevaluepair("pass","password")); namevaluepairs.add(new basicnamevaluepair("uuid", "0xaca021")); httppost.setentity(new urlencodedformentity(namevaluepairs)); // execute http post request log.w("sencide", "execute http post request"); httpresponse response = httpclient.execute(httppost); string str = inputstreamtostring(response.getentity().getcontent()).tostring(); log.w("sencide", str); if(str.tostring().equalsignorecase("true")) { log.w("sencide", "true"); result.loaddata(str,"text/html", "utf-8"); }else { log.w("sencide", "false"); result.loaddata(str,"text/html", "utf-8"); } } catch (clientprotocolexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); }
Comments
Post a Comment