http - Login to webpage from android app -


i'm quite new in android , today came across problem. want login website:

http://pedidos.pizzeriabritannia.com/index.asp?opc=pedir

and retrieve data source code, don't know start. give me advice or literature deal issue?

thank mates!

i've following code:

public void postlogindata() {     // create new httpclient , post header     httpclient httpclient = new defaulthttpclient();      /* login.php returns true if username , password equal saranga */     httppost httppost = new httppost("http://pedidos.pizzeriabritannia.com/index.asp?opc=pedir");      try {         // add user name , password           list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(2);         namevaluepairs.add(new basicnamevaluepair("username", "942037851"));         namevaluepairs.add(new basicnamevaluepair("password", "xxxxxx"));         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");          et1.settext("login successful");            }else         {          log.w("sencide", "false");          et1.settext("login not successful");                      }      } catch (clientprotocolexception e) {      e.printstacktrace();     } catch (ioexception e) {      e.printstacktrace();     } }   private stringbuilder inputstreamtostring(inputstream is) {  string line = "";  stringbuilder total = new stringbuilder();  // wrap bufferedreader around inputstream  bufferedreader rd = new bufferedreader(new inputstreamreader(is));  // read response until end  try {   while ((line = rd.readline()) != null) {      total.append(line);    }  } catch (ioexception e) {   e.printstacktrace();  }  // return full string  return total; } 

what asking called data scraping. you'll have parse return html value. can make own suitable html parser i'd recommend library such.


Comments

Popular posts from this blog

java - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -