This article mainly introduces the PHP implementation and the Android client query interaction, interested in the friend's reference, I hope to be helpful to everyone.
PHP Server side:
function GetIDs () {$this->output->set_header (' Content-type:application/json; Charset=utf-8 '); $jsonstr = "; $pname = $pcallid = $pworkid = "; if (isset ($_get[' name ')) {$pname = $_get[' name ']; } if (Isset ($_get[' callid ')) {$pcallid = $_get[' callid ']; } if (Isset ($_get[' WorkID ')) {$pworkid = $_get[' WorkID ']; } $this->load->model (' Wireid_model '); $this->wireid_model->insertonly ($pname, $pcallid); if ($pname = = ' && $pcallid = = ' && $pworkid = = ') {die (); } else {$sqlstr = ' select * from Twireid where 1=1 '; if ($pname! = ") {$sqlstr = $sqlstr. "and Gname= ' {$pname} '"; } else if ($pcallid! = ") {$sqlstr = $sqlstr. "and Goldcallid= ' {$pcallid} '"; } else if ($pworkid! = ") {$sqlstr = $sqlstr. "and Gcardid= ' {$pworkid} '"; } $getdata = $this->wireid_model->getsql ($SQLSTR); Json_force_object prevent the appearance of [] $jsonstr = Json_encode ($getdata-> Result_array (), json_force_object); Echo $jsonstr; }}
Java android:
Doasktask = new Runnable () {@Override public void run () {//TODO//HTTP request here. Network requests related Operations GGN ame = Etname.gettext (). toString (); Ggworkid = Etworkid.gettext (). toString (); Ggcallid = Etcallid.gettext (). toString (); String BaseURL = Confiddatas.askbaseurl; String askstr = "Name=" + ggname + "&callid=" + ggcallid + "&workid=" + ggworkid; String result = null; HttpGet httpget = new HttpGet (BaseURL + askstr); The second step is to use the Execute method to send an HTTP GET request and return the HttpResponse object HttpResponse httpresponse = null; try {HttpResponse = new defaulthttpclient (). Execute (httpget); } catch (Clientprotocolexception e) {//TODO auto-generated catch block E.printstacktrace (); } catch (IOException e) {//TODO auto-generated catch block E.printstacktrace (); } Message msg = new Message (); Bundle data = new bundle (); if (Httpresponse.getstatusline (). Getstatuscode () = =200) {///third step, use GetEntity method to live return result try {result = Entityutils.tostring (httpresponse.getentity ()); Data.putstring ("value", result); Data.putstring ("Result", "isOK"); Msg.setdata (data); Handler.sendmessage (msg); } catch (ParseException e) {//E.printstacktrace (); } catch (IOException e) {//E.printstacktrace (); }} else {//Error data.putstring ("Value", ""); Data.putstring ("Result", "iserr"); Msg.setdata (data); Handler.sendmessage (msg); } } };
Summary : The above is the entire content of this article, I hope to be able to help you learn.
Related recommendations:
PHP uses the Snoopy class to implement the page crawl method
PHP class inheritance and extended operation skills
How PHP reads the lattice data of Chinese characters