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;
}