0

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;
}
2
  • @stillstanding Yes. Everything works fine from a browser Commented Dec 7, 2010 at 15:25
  • @Tokk No. I tried copying and pasting from the debugger. Worked fine. Commented Dec 7, 2010 at 15:26

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the tip. I'll need that, but I just tried to comment out the ssl line(s!) to see if that was it, unfortunately not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.