I am going through this example of REST web service to salesforce from PHP app, and I was getting the same errors described here. I tried to implement more permanent solution with
curl_setopt($curl, CURLOPT_CAINFO, 'C:\dev\curl\cacert.pem');
from here http://kb.ucla.edu/articles/how-do-i-use-curl-in-php-on-windows .
I downloaded cacert.pem from this link http://curl.haxx.se/docs/caextract.html .
It works for the example with google ("https://encrypted.google.com/";) , but does not work with salesforce. I am getting the following error:
Error: call to token URL https://test.salesforce.com/services/oauth2/token failed with status 400, curl_errno() 0, curl_error() , response {"error":"unsupported_grant_type","error_description":"grant type not supported"}
Any ideas please how to fix it?