Running PHP script from server Android SDK -
So, looking at how to run a PHP script from the Android app, I came into this code:
last string url = "http://example.com/creatd.php?nm=mytest"; HTTP Client Client = New DefaultHttpClient (); Try {Client.execute (new HttpGet (url)); Intent = intent (new, main section); StartActivity; } Hold (IOE Execution E) {// Here is Here} Basically, I assumed that this would work because the client Execute executes the script in the url. However, till now I did not know that the HTTP Gate got information from running the script. My PHP script does not provide information, it only executes a task on the server (make me correct if I am wrong on HTTPPLant)
How do I create it then the client? Execute only executes scripts instead of just getting information about it? I am thinking for this reason that my app is crashing because the script does not return any information, value is zero.
PHP Code:
& lt ;? Php $ str = $ _GET ['nm']; Mkdir ($ str, 0700); Fopen ($ str. "/" Str str. ".mb", "w"); File_put_contents ($ str. "/". Str. ". Meb", "Hello, World!", FILE_APPEND | LOCK_EX); ? & Gt; Edit: Just one question, why do people reject my questions? I searched my question and tried to use the solution, but the solutions provided did not work. What am i doing wrong
Thanks to the ghost, I have solved the problem and it has been added to it in a thread.
last string url = "http://example.com/perform.php?nm="+string; New thread () {@ Override public wide run (try {try} {httpclient = new DefaultHttpClient (); HttpResponse response = httpclient.execute (new HttpGet (url)); Threaded Positions = Response .getStatusLine (); If (statusLine.getStatusCode () == HttpStatus.SC_OK) {Baitareotputstrym out = new Baitareonputstrym (); Try {response.getEntity () WriteTo (outside); Out.close (); } Grip (IOException E) {} string response string = out.Testine (); //..and logic) and {// connection closes try {response.getEntity ()) GetContent () Close (); Throw New IOException (statusLine.getReasonPhrase ()); } Catch (IOE EXPRESS E) {}}} Catch (Client Protocol E) {} Catch (IOE EXPRESS E) {}}}. Start (); Again, thank you to the ghost.
Comments
Post a Comment