Get response from php to GETRequest from android studio

0

I'm trying to send a request to a php file using the GETRequest method from Android, the request looks like this:

public void send(String lat, String lon) throws Exception {
    String url = "http://simon.cuccfree.com/gps.php?lat="+lat+"&lon="+lon;

    URL send = new URL(url);
    HttpURLConnection con =  (HttpURLConnection) send.openConnection();

    //Selecciona el GET como el metodo a usar
    con.setRequestMethod("GET");

    int responseCode = con.getResponseCode();
    System.out.println("\nEnviando datos al servidor: " + url);
    System.out.println("Codigo de respuesta: " + responseCode);

    BufferedReader in = new BufferedReader(
            new InputStreamReader(con.getInputStream()));
    String inputLine;
    StringBuffer response = new StringBuffer();

    while ((inputLine = in.readLine()) != null) {
        response.append(inputLine);
    }
    in.close();

    //Muestra el resultado
    System.out.println(response.toString());   
}

In the php I'm doing a echo that contains text as follows:

gps.php

<?php
   $respuesta = "Ok";
   echo($respuesta);
?>

I would like to get Ok , but I am getting this answer:

<html>
<body>
    <script type="text/javascript" src="/aes.js" ></script>
    <script>function toNumbers(d){var e=[];d.replace(/(..)/g,function(d){e.push(parseInt(d,16))});return e}function toHex(){for(var d=[],d=1==arguments.length&&arguments[0].constructor==Array?arguments[0]:arguments,e="",f=0;f
        <d.length;f++)e+=(16>d[f]?"0":"")+d[f].toString(16);return e.toLowerCase()}var a=toNumbers("f655ba9d09a112d4968c63579db590b4"),b=toNumbers("98344c2eee86c3994890592585b49f80"),c=toNumbers("3e4f749128034cc64269f23838a6e5c6");document.cookie="__test="+toHex(slowAES.decrypt(c,2,a,b))+"; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/"; location.href="http://simon.cuccfree.com/gps.php?lat=32&lon=10";
        </script>
        <noscript>This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support</noscript>
    </body>
</html>

I would like to know how to obtain the value of the variable and not the fragment of HTML

    
asked by SMN947 24.08.2017 в 03:46
source

0 answers