Sending a response from PHP to an Android/Java mobile app?
<p>I currently have a piece of code in my Android application that picks up the devices IMEI and sends that IMEI as a parameter to a PHP script that is hosted on the Internet. </p>

<p>The PHP script then takes the IMEI parameter and checks a file to see if the IMEI exists in the file, if it does I want to be able to let my Android application know that the IMEI exists. So essentially I just want to be able to return True to my application.</p>

<p>Is this possible using PHP?</p>

<p>Here is my code so far:</p>

<p>Android/Java</p>

<pre><code>//Test HTTP Get for PHP

        public void executeHttpGet() throws Exception {
            BufferedReader in = null;
            try {
                HttpClient client = new DefaultHttpClient();
                HttpGet request = new HttpGet();
                request.setURI(new URI("http://testsite.com/" +
                        "imei_script.php?imei=" + telManager.getDeviceId()
                        ));
                HttpResponse response = client.execute(request);
                in = new BufferedReader
                (new InputStreamReader(response.getEntity().getContent()));
                StringBuffer sb = new StringBuffer("");
                String line = "";
                String NL = System.getProperty("line.separator");
                while ((line = in.readLine()) != null) {
                    sb.append(line + NL);
                }
                in.close();
                String page = sb.toString();
                System.out.println(page);
                } finally {
                if (in != null) {
                    try {
                        in.close();
                        } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
</code></pre>

<hr>

<p>The above sends the IMEI as a parameter to the PHP script which picks it up successfully and runs a check against the file successfully, however I neeed to then be able to send a positive response back from the PHP script if the IMEI matches one in the file.</p>

<p>Here is the PHP:</p>

<pre><code>&lt;?php
    // to return plain text
    header("Content-Type: plain/text"); 
    $imei = $_GET["imei"];

    $file=fopen("imei.txt","r") or exit("Unable to open file!");

    while(!feof($file))
     {
    if ($imei==chop(fgets($file)))
     echo "True";
     }

    fclose($file);

?&gt;
</code></pre>

<hr>

<p>So instead of echo True I want to be able to let my application know that the IMEI was found, is this possible and if so what should I be using to achieve it?</p>
