While trying to parse JSON string to Android, HTML values are passed instead. Previously, the code worked well, but suddenly began crashing when fetching a database with the help of PHP files.
Upon checking, HTML values were observed in the logcat:
<html><body><h2>Checking your browser..</h2><script...
The main problem is that ByetHost implements a simple security anti-bots module named testcookie-nginx-module.
The testcookie-nginx-module performs a two-step validation:
To bypass this validation in Android, follow these steps:
Get the cookie key from a web browser:
Set the cookie on your Android app:
In your code that makes the HTTP request, add the following header:
<code class="java">httpPost.addHeader("Cookie", "__test=<content-of-your-cookie>; expires=<expires>; path=<path>");</code>
The above is the detailed content of How to Fix ByetHost\'s testcookie-nginx-module Blocking JSON Responses in Android Apps?. For more information, please follow other related articles on the PHP Chinese website!