cURL PHP RESTful service always returning FALSE cURL PHP RESTful service always returning FALSE curl curl

cURL PHP RESTful service always returning FALSE


$response is likely false because curl_exec() returns false (i.e., failure) into $result. Echo out curl_error($ch) (after the call to curl_exec) to see the cURL error, if that's the problem.

On a different note, I think your CURLOPT_POSTFIELDS is in an invalid format. You don't pass a JSON string to that.

This parameter can either be passed as a urlencoded string like 'para1=val1&para2=val2&...' or as an array with the field name as key and field data as value.

-- PHP docs for curl_setopt()


Update

The quick way to avoid the SSL error is to add this option:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

You get an SSL verification error because cURL, unlike browsers, does not have a preloaded list of trusted certificate authorities (CAs), so no SSL certificates are trusted by default. The quick solution is to just accept certificates without verification by using the line above. The better solution is to manually add only the certificate(s) or CA(s) you want to accept. See this article on cURL and SSL for more information.