CURL status 200 but Response is empty

  api, curl, libcurl, php

i’m trying to call an API using curl request, unfortunately i’m getting empty response and curl status is 200. But while hitting the API in browser directly i’m getting JSON data. here’s my code

$url="API_URL";
$ch = curl_init($url);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
 curl_setopt($ch,CURLOPT_TIMEOUT_MS,1500);
 $result = curl_exec($ch);          
 $curl_info = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 $curl_err = curl_error($ch);
 curl_close($ch);
 $data = json_decode($result, true);

Thanks in advance!

Source: Ask PHP

LEAVE A COMMENT