Jaymin Sejpal Jaymin Sejpal - 4 years ago 139
JSON Question

cUrL in php : Nothing come in response [NULL]

I am fetching data from thirdparty API using CURL in php. I have read the documentation and passing the same valid parameters to the request but nothing works.
I am showing the code removing "API KEY" due to confidentiality.

$service_url = 'https://api.birdeye.com/resources/v1/business/147197756121167?api_key=ApiKeyGoesHere';
$curl = curl_init($service_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$curl_response = curl_exec($curl);
if ($curl_response === false)
$info = curl_getinfo($curl);
echo '<pre>';
die('error occured during curl exec. Additioanl info: ' . var_export($info));

$decoded1 = json_decode($curl_response,true);
if (isset($decoded1->response->status) && $decoded1->response->status == 'ERROR')
die('error occured: ' . $decoded1->response->errormessage);
echo 'response ok!';

The Output it gives me is :
response ok!NULL

Link to the documenataion of birdeye API.


I have tried testing with Terminal it gives me response.
Can Any One give me the way, where I am going wrong?

Answer Source

Try this with your api key

 $urltopost = 'https://api.birdeye.com/resources/v1/business/147197756121167?api_key=ApiKeyGoesHere';
 $ch = curl_init ($urltopost);
 curl_setopt ($ch, CURLOPT_POST, true);
 curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
 curl_setopt ($ch, CURLOPT_HTTPHEADER, $header);
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
 $returndata = curl_exec ($ch);
 $status_code = @curl_getinfo($ch, CURLINFO_HTTP_CODE); 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download