I have a piece of php code to curl an API endpoint, it returns a json string. But the string is chopped off to be 16042 characters long, so my json_decode function fails due to invalid format json string.
My question is "Is there a limit for the curl return value ? "
$ch = curl_init ();
$timeout = 5;
curl_setopt ( $ch, CURLOPT_URL, $url );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $ch, CURLOPT_CONNECTTIMEOUT, $timeout );
curl_setopt ( $ch, CURLOPT_HEADER, true );
$output = curl_exec ( $ch );
$header_size = curl_getinfo ( $ch, CURLINFO_HEADER_SIZE );
$body = substr ( $output, $header_size );
Or is the substr function chopping it off ?
Exaplanation
The
CURLOPT_HEADER
includes the header in the output. Need to set it tofalse
or remove it. Click here for reference.