views:

130

answers:

1

I'm trying to write a class that can add a bookmark to my Delicious account.
Here's my method:

public function addBookmark($url, $description) {   
 $dusername = 'myUsername';  
 $dpassword = 'myPassword';  
 $api = 'api.del.icio.us/v1';  
 $link = urlencode($url);  
 $desc = urlencode($description);  
 $apicall = "https://$dusername:$dpassword@$api/posts/add?&url=$link&description=$desc";  
 $ch = curl_init($apicall);  
 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);  
 curl_setopt($ch, CURLOPT_USERAGENT, 'php - curl');  
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
 $xml = curl_exec($ch);   
}

In the real code, $dusername and $dpassword are my actual credentials.

When called from PHP, it fails to add a bookmark. However if I echo $apicall, and go to it directly with FireFox, the bookmark is added. So, this makes me assume there's an error in my cURL implementation. I tried commenting out the lines where it sets CURLOPT_SSL_VERIFYHOST and CURLOPT_USERAGENT, but that didn't work either.

This is driving me crazy because at first I rolled my own code, which didn't work. Now I'm using code someone has (allegedly) got working for themselves, and still no luck.

Any help is greatly appreciated, thanks!

+2  A: 

It seems you have a problem verifying the Certificate Authority's certificate. Not sure how you fix this but you might be able to sidestep it like this:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
Greg
This did the trick. Thanks!
Arms