Search code examples
phpandroidmysqlhttp-status-code-403

Android httpPost(URL) -> 403 Forbidden


I'm working on an Android App that sends data to a server (hosted in hostinger.es - for free to test the app) via new HttpPost(url); howevere, when I run the app in my cellphone, I always get the following answer in my logs:

09-03 15:24:40.916: response: 
<html>
<head>
<title>Error 403 - Forbidden</title>
<meta http-equiv="Refresh" content="0;url=http://www.hostinger.co/error_404?" />
</head>
<body>
</body>
</html>

My server code is php/mysql. I've changed the permissions in FileZilla of my folders and files .php but still getting same answer.

Code of my client for the request:

private static final String url = "http://yyy.esy.es/XXXX/process.php/senddata/";
// yyy subdomain in hostinger
// XXXX the folder where my php files are

protected void sendDataToServer(final TestData data) {
    ArrayList<NameValuePair> keyValuePairs = new ArrayList<NameValuePair>();
    keyValuePairs.add(new KeyValuePair(Constant.FB_ID, data.getId()));

    ....
    ResponseHandler<String> res = new BasicResponseHandler();
    HttpPost postMethod = new HttpPost(url);

    // Data that is to be sent
    postMethod.setEntity(new UrlEncodedFormEntity(keyValuePairs));

    // Execute HTTP Post Request
    String response = httpClient.execute(postMethod, res);

Could someone please help me?

Thanks in advance


Solution

  • Thanks for the answer. The problem is that hostinger does not allow remote connections to the Database in the free account, I didn't know that. To solve the problem, I've changed to other free web hosting provider and now it's working fine.