ByeHost Server Sending HTML Values "Checking Your Browser" with JSON String
Question:
When trying to parse a JSON string to Android, HTML values are passed. Everything was functioning fine until a day ago, but suddenly when trying to get the database using a PHP file, my application started crashing.
When I checked, noticed the HTML value, see logcat.
Answer:
The solution is:
ByeHost uses an antibots security module called testcookie-nginx-module. This module performs two-step verification on HTTP requests:
Step 1: On the first request, the module returns a JavaScript that generates the verification cookie.
Step 2: On subsequent requests, the client will add the authentication cookie and the module will verify the cookie AES key and allow the request to continue.
<code class="java">httpPost.addHeader("Cookie", "__test=THE_CONTENT_OF_YOUR_COOKIE_HERE; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/");</code>
With these steps, the application will include cookies to pass validation and the expected JSON data can be retrieved.
The above is the detailed content of The following are several English titles suitable for the content of the article, presented in a question and answer format: 1. Why is my Android app receiving HTML instead of JSON data from a ByeHost server? 2. How do I fix the \'Checking Your Browser\' error when fetching JSON data fro. For more information, please follow other related articles on the PHP Chinese website!