Android Jsoup login to get response -


i trying response failure or success login mobile website. here part of code.

edit


public string login(string user, string pass) throws exception{ // create new httpclient , post header httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost(amwayurl); string result = "nothing"; try { // add user name , password string username = user; string password = pass; list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(2); namevaluepairs.add(new basicnamevaluepair("userid", username)); namevaluepairs.add(new basicnamevaluepair("userpswd", password)); httppost.setentity(new urlencodedformentity(namevaluepairs)); cookiestore cookiestore = new basiccookiestore(); httpcontext localcontext = new basichttpcontext(); localcontext.setattribute(clientcontext.cookie_store, cookiestore); httpresponse response = httpclient.execute(httppost, localcontext); result = inputstreamtostring(response.getentity().getcontent()).tostring(); httpentity entity = response.getentity(); system.out.println("----------------------------------------"); system.out.println(response.getstatusline()); if (entity != null) { system.out.println("response content length: " + entity.getcontentlength()); } list<cookie> cookies = cookiestore.getcookies(); (int = 0; < cookies.size(); i++) { system.out.println("local cookie: " + cookies.get(i)); } // consume response content //entityutils.consume(entity); system.out.println("----------------------------------------"); } catch (clientprotocolexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } { // when httpclient instance no longer needed, // shut down connection manager ensure // immediate deallocation of system resources httpclient.getconnectionmanager().shutdown(); } return result; } 

i response , if examine can see did perfomed login question how use programmatic way find out if login successful?

i cannot use redirect code since site stays on same page.

pass response string , follow official doc parse !

http://jsoup.org/cookbook/input/parse-document-from-string

if need parse specific element can do:

doc.select(your css query here searching tag, element, class, id or atribute value) 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -