Freebase API call works in browser but fails with curl Freebase API call works in browser but fails with curl json json

Freebase API call works in browser but fails with curl


For me by adding the below line worked.

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 


My guess is that you are seeing NULL because the curl_exec returns false and then the json_decode converts the false to NULL.

This means, as you suspected, that curl_exec is failing. I'm not sure why, but I would start by debugging with curl_error() and curl_errno() to get more information on what is causing curl to fail.

Reference: curl_exec() always returns false