J'essaie d'appeler un site sur localhost d'un autre également sur localhost en utilisant CURL en PHP. (Il est un test)appel localhost site à partir d'un autre site localhost en utilisant PHP CURL
J'utilise windows 7
Les deux sont mis en place dans le fichier hôte et fonctionne très bien si on y accède directement
je reçois une erreur 404. Si j'appelle un site sur le web alors ça revient bien.
N'est-ce pas possible?
protected function get($url)
{
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if($httpCode != 200)
throw new CHttpException($httpCode, 'Curl Error : ' . $response);
return $response;
}
utilisez-vous vhosts? – stillstanding
peut-être une faute de frappe dans votre URL? – Tokk
@stillstanding Oui. Tout fonctionne très bien depuis un navigateur – SystemicPlural