0
我使用卷曲获得来自API调用下载的Excel文件,在我的API调用它返回一个Excel文件中的一个,卷曲API调用下载的文件
我喜欢强制下载软件,Excel文件,怎么能我用卷曲来做这个?
我试图像这样: -
$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);
这里有个答案http://stackoverflow.com/questions/22155882/php-curl-download-file – motanelu
不,不像t帽子。我的API响应没有填写文件。不与数据的响应只包含下载文件。但insted下载文件。 @motanelu –