0

I had a lot of trouble figuring out why my php Curl API worked fine on a Mac using MAMP, but would not work under windows.

I asked fot debugging tips or useful information for finding curl configuration issues under windows.

The accepted answer contains a list of the steps that helped me get curl working on windows 7 32 bits.

helloworld
  • 527
  • 6
  • 21

3 Answers3

1

If Curl still doesn't work, you can use file_get_contents to make POST requests. It works on all hostingers, all OS and on local.

    $url = 'WhateverUrlYouWant';
    $postdata = http_build_query(
        array(
            'id' => '202',
            'form' => 'animal',
            .....
        )
    );
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => 'Content-type: application/x-www-form-urlencoded',
            'content' => $postdata
        )
    );
    $context  = stream_context_create($opts);
    $result = file_get_contents($url,false, $context);
    echo $result
hp95
  • 25
  • 1
  • 10
  • I appreciate your answer. But I need curl to run an API. The post example is just an oversimplifcation of the problem. – helloworld Jul 10 '15 at 18:34
  • Maybe : Copy the files libeay32.dll and ssleay32.dll in C:\Windows\System32\ Copy the file php_curl.dll in c:\wamp\bin\php\php[your actual version]\ext\ – hp95 Jul 10 '15 at 18:40
  • Maybe, you simple forget to activate it ;) Left-click on the WAMP server icon in the bottom right of the screen PHP -> PHP Extensions -> php_curl – hp95 Jul 10 '15 at 18:44
  • Nope. Curl is enabled. – helloworld Jul 10 '15 at 18:47
  • 1
    It is your case : http://stackoverflow.com/questions/20262524/no-response-getting-from-curl-request-to-https-server – hp95 Jul 10 '15 at 18:53
0

Here is a list of steps for debugging Curl:

Check in phpinfo module that Curl IS enabled.

Verify extensions dir path is propperly set in php.ini and that extension=php_curl.dll is uncommented.

Check that Environment Variables are propperly set as per: http://php.net/manual/en/faq.installation.php#faq.installation.addtopath

Run deplister.exe ext\php_curl.dll to verify all dependencies are correctly satisfied.

If all of the above is working then check the output of CURLOPT_VERBOSE. As per @hp95 suggestion in the following thread: No Response getting from Curl Request to https server

If you are reaching a site that uses SSL check the following post: HTTPS and SSL3_GET_SERVER_CERTIFICATE:certificate verify failed, CA is OK

And fix it like these:

https://snippets.webaware.com.au/howto/stop-turning-off-curlopt_ssl_verifypeer-and-fix-your-php-config/

Community
  • 1
  • 1
helloworld
  • 527
  • 6
  • 21
-1

reverse

  • curl_close($curl); print_r($response); ** this is a broken protocol **

to

  • print_r($response); curl_close($curl); ** print your results BEFORE closing, which destroys (empties) the $response **
jobeard
  • 129
  • 6