Using PHP CURL on Ubuntu
I ran into an issue when trying to hit the IMified API using PHP's CURL functions on Ubuntu. I thought I'd share the problem I ran into and the fix in case others run into this issue.
Following the examples on the IMified site for using the API
with PHP (http://www.imified.com/developers/api#api),
I was able to successfully test API calls on my local development
machine. However, when I moved to a hosted environment to run more
tests, all of my API calls failed.
Because the API uses SSL you need to have the "ca-certificates" package installed if you are running Ubuntu. If you are testing API calls and the results are not what you expect, make sure you first check for errors using PHP's curl_error() function. If you see an error like this:
"error setting certificate verify locations: CAfile: /etc/ssl/certs/ca-certificates.crt CApath: none"
It means you need to install the ca-certificates package. Check the version of Ubuntu that you are running:
$ cat /etc/lsb-release
Then you should be able to install the package using:
$ sudo apt-get install ca-certificates
(I ran this on Hardy and it worked just fine.)
Hope this helps anyone else running into this same issue.
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Adam Kalsey on 01 Dec, 2009 05:44 PM
Great stuff. I'm going to put this in a Knowledge base article.