0

I have opened up 4 months old android project and I faced some problems which I didn't have before.

I have a web-service http://tojesttest.byethost22.com/PizzaService/getAndroidOrders.php which gets me JSONArray when I open it in a browser, but when I call it from inside of android app it gets me in return:

10-16 21:29:35.021 18477-18565/com.example.tomek.pizzaservice E/HTTP: Success!<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("cd6163c2d295cc64f22c62356ba045f4");document.cookie="__test="+toHex(slowAES.decrypt(c,2,a,b))+"; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/";location.href="http://tojesttest.byethost22.com/PizzaService/getAndroidOrders.php?ckattempt=1";</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've tried to enable java script in android Internet browser but it was already turned ON.

Piece of code that I'm using:

private static JSONArray loadFromDatabase(String phpFileAddress){
    JSONArray jsonArray = null;

    OkHttpClient client = new OkHttpClient();
    Request request = new Request.Builder().url(phpFileAddress).build();

    Call call = client.newCall(request);
    call.enqueue(new Callback() {
        @Override
        public void onFailure(Request request, IOException e) {
            Log.e("HTTP", "onFailure");
        }

        @Override
        public void onResponse(Response response) throws IOException {
            try {
                final String jsonData = response.body().string();
                if (response.isSuccessful()) {
                    Log.e("HTTP","Success!" + jsonData);
                } else {
                    Log.e("HTTP","Zła odpowiedź serwera.");
                }
            }
            catch (IOException e) {
                Log.e("HTTP","Zła odpowiedź serwera.");
            }
        }
    });



    return jsonArray;
}
Tomasz Mularczyk
  • 27,156
  • 17
  • 99
  • 146
  • Check value phpFileAddress – user2413972 Oct 16 '15 at 19:55
  • @user2413972 checked. It's good. – Tomasz Mularczyk Oct 16 '15 at 19:59
  • Judging by the content of the response, your request gets the wrong way. – user2413972 Oct 16 '15 at 20:01
  • 1
    Looks like the hosting company may have changed things on the server, see here: http://stackoverflow.com/questions/32409655/getting-html-response-instead-of-json-in-android and here: http://stackoverflow.com/questions/32667953/when-accessing-webpage-in-java-the-body-of-my-php-page-becomes-error-about-java – Daniel Nugent Oct 16 '15 at 20:10
  • @DanielNugent This seems like an answer(and yes I see they made some major changes). I wonder can it be fixed somewhere inside account control panel or do I have to search for other web hosting service. – Tomasz Mularczyk Oct 16 '15 at 20:32
  • 'This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support'. Did you see that? Please format your output so we don't have to scroll halve an hour to the right. You can conclude that the javascript gets the json text. – greenapps Oct 17 '15 at 07:11
  • @greenapps yes I saw it and mentioned about it in my question. – Tomasz Mularczyk Oct 17 '15 at 07:31
  • You are not reacting to the point though because you also mentioned that javascript was enabled in your browser. But the browser is just an app. It can be enabled in all apps but if it is not enabled in your app your app will not work. You did not show that you realised that. – greenapps Oct 17 '15 at 08:11
  • @greenapps how can I enable javascript in my app? – Tomasz Mularczyk Oct 17 '15 at 16:43
  • You can't. Unless you have build in a javascript interpreter. Which i think you haven't. – greenapps Oct 17 '15 at 21:05

0 Answers0