I have an API, when I run that API in chrome, it will get download directly excel sheet, but now I want to run that API in CURL php code in my server, how can I do that one.
I tried :
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 300);// if file large
curl_setopt($ch, CURLOPT_URL, "MyAPI");
$return=curl_exec($ch);
print_r($return);
echo "<br>";
// the important part
$destination ="files.csv";
if (file_exists( $destination)) {
unlink( $destination);
}
$file=fopen($destination,"w+");
fputs($file,$return);
if(fclose($file))
{
echo "downloaded";
}
curl_close($ch);
file.csv coming into server but result is coming only 1,
print_r($return) result is 1 but actually I have 10 records in that excel sheet.
Could any one help on it please?
Thanks Sandeep