Search code examples
phpandroidurlutf-8encode

403 forbidden when trying to call a URL using get variable in php


I am trying to make a request from Java (Android) to send a URL to a php file hosted on a web server. wv.loadUrl(baseurl + "?url=" + URLEncoder.encode(url,"UTF-8"));

where wv is a web view.

The url generated using the above command is: http://divu.in/TheRedDevil/readhtml/index.php?url=http://www.manutd.com/en/News-And-Features/Football-News/2013/Oct/jimmy-nicholl-knows-jonny-evans-will-battle-for-place.aspx

I also manually tried to open this link using browser and in both cases I got a 403 forbidden error.

Is it a hosting security issue or I am doing something wrong ? How can this be solved ?


Solution

  • As others have suggested it is not a problem with Android, it is a problem with your PHP code or host. It seems like your host somehow disallows loading external files. If you are using file_get_content to load the external content you might try using curl instead - maybe they don't block that.

    <?php 
    $curl = curl_init('http://www.example.com'); 
    $result = curl_exec($curl); 
    echo $result; 
    ?>