not getting response using curl. I have put all solution but did not get response.
$ch = curl_init(); $header = array('api_key:xxxxxxxxxxxxxxxx','Content-Type: application/json'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 0); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); if($postdata!=""){ curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); } $response = curl_exec($ch); curl_close($ch); $result = json_decode($response,true); print_r($result); // not display result this example not displaying any result but it send to specific place.
($ ch, CURLOPT_HEADER, 1) ;: Causes header information to be contained in $ response. Thus, $ response is no longer a pure JSON string. That's why this non json_decode can be converted into an Object / Array. (Ergnis is null) My approach: curl_setopt($ ch, CURLOPT_HEADER, 0);We refrain from returning the headers and receive a pure JSON that can be further processed.