I am trying to call a site on localhost from another also on localhost using CURL in PHP. (It's a test)
I'm using windows 7
Both are set up in the host file and work fine if accessed directly
I get a 404 error. If I call a site on the web then it comes back fine.
Is this not 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_COD开发者_高级运维E);
if($httpCode != 200)
throw new CHttpException($httpCode, 'Curl Error : ' . $response);
return $response;
}
Since you set SSL options you probably use https. However on Windows you have to tell cURL where to find the certificate(s). Try curl_setopt($curl, CURLOPT_CAINFO, 'C:\path\to\curl-ca-bundle.crt');
.
精彩评论