Translate cURL command line into PHP cURL
You need to provide curl with the certificate chain that will allow it to verify Twitter's SSL certificate as valid. To do this, download the requisite certificate signatures from here and save them into a plain file (I 'll assume you name it cacert.pem
).
Then, before making the request, set CURLOPT_CAINFO
to point to this file:
// assumes file in same directory as scriptcurl_setopt($ch, CURLOPT_CAINFO, 'cacert.pem');
It's also a good idea to explicitly enable SSL certificate verification instead of relying on default settings:
curl_setopt($ch, CURLOPT_VERIFYPEER, true);