I have a php script called query3.php that returns the max punctuations from an Android game, stored in a mysql database.
It worked perfectly til today, but now it returns Access denied err403. I haven't made any changes in the code.
The curious thing is that if I enter the url in a browser, it works ok, and I see the JSON encoded data. The problem occurs only when I access from my Android App.
In the Access logs of the database it appears like this:
xxxxxxxxxxxxxxxx.com [27/Jun/2015:10:48:42 -0500] 90.174.2.74 - - "POST /query3.php HTTP/1.1" 403 18 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)"
It might be something new they configured in the server?. I wrote to them but didn't get response yet.
I think you may need to set the User-Agent header in your JSON request. Try adding a line in JSONParser file where you making HttpRequest() before the call to execute() like:
httpPost.setHeader('User-Agent','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36');
I faced the same problem.. This solution was given by @morphatic and it worked perfectly in my case.. DO vote him up.. JSON is showing error 403 while trying to fetch data from database in android