0

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!

Steven Mercatante
  • 24,757
  • 9
  • 65
  • 109
  • Are you getting a specific error message? – brettkelly Sep 21 '09 at 20:39
  • Sadly, no. I wish I was. I was using curl_getinfo(), but it didn't spit any error messages out. The Delicious API is supposed to return an XML response, but I wasn't receiving any. – Steven Mercatante Sep 21 '09 at 20:41
  • This is what curl_error() returned: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed – Steven Mercatante Sep 21 '09 at 20:45

1 Answers1

2

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
  • 316,276
  • 54
  • 369
  • 333