SystemicPlural
SystemicPlural

Reputation: 5789

calling localhost site from another localhost site using PHP CURL

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_CODE);
    if($httpCode != 200)
        throw new CHttpException($httpCode, 'Curl Error : ' . $response);
    return $response;
}

Upvotes: 0

Views: 920

Answers (1)

rik
rik

Reputation: 8612

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');.

Upvotes: 1

Related Questions