Fopen wrappers désactivés par mon hébergeur

Nymphomaniaque Messages postés 55 Date d'inscription   Statut Membre Dernière intervention   -  
Nymphomaniaque Messages postés 55 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,


J'ai sur une page php ce bout de code qui ne marche pas
$stringIp = $_SERVER['REMOTE_ADDR'];
$xml = file_get_contents('http://api.hostip.info/?ip='.$stringIp);

J'ai écrit à mon hébergeur. Celui-ci m'informe que :

file_get_contents is enabled, however fopen wrappers are disabled on hosting so you will not be able to do a remote get.
cURL is enabled on free hosting but can only access port 80.


Je ne sais pas comment je peux faire pour remédier au problème tout en restant dans l'hébergement gratuit ?

2 réponses

Zep3k!GnO Messages postés 2025 Date d'inscription   Statut Membre Dernière intervention   200
 
0
Nymphomaniaque Messages postés 55 Date d'inscription   Statut Membre Dernière intervention   4
 
oui, j'ai essayé comme ceci :

d'abord j'ai défini la fonction

function http_fetch_url($url, $timeout = 10)
{
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}


Puis, je lui ai fait appel :

        $stringIp = $_SERVER['REMOTE_ADDR'];
	$fch=sprintf('http://api.hostip.info/?ip=%s',$stringIp);
        $xml=http_fetch_url($fch,10);
0