Wednesday, July 15, 2009

I get no response when using curl with SSL

PHP 5.2.9-2/Windows XP SP2

Fix:

add curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

Example:

Get all posts from Delicious:

$fetch_url ="https://api.del.icio.us/v1/posts/all?";
$curl = curl_init();
curl_setopt( $curl, CURLOPT_URL, $fetch_url );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt( $curl, CURLOPT_USERPWD,"username:password");
curl_setopt( $curl, CURLOPT_CONNECTTIMEOUT, 30 );
curl_setopt( $curl, CURLOPT_TIMEOUT,5 );
curl_setopt( $curl, CURLOPT_POST, 1 );
$response = curl_exec( $curl );
curl_close( $curl );
header("Content-Type:text/xml");
echo $response;

No comments:

Post a Comment