I’m using curl to get downloaded Excel file from an api call, in one of my api call it returns a excel file,
I like to force download that Excel file , how can i do this with curl ?
I tries Like this :-
$url = 'http://xyzwebsite.com/GetExcelParameterScheet'; $fields = array('TemplateID' => $id); $method = 'POST'; // Open connection $ch = curl_init(); // Set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); // Disabling SSL Certificate support temporarly curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); // Execute post $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } // Close connection curl_close($ch);