我正在尝试调用ConvertAPI.com/Word2Pdf,但没有成功。
我的示例代码是:
$fileToConvert = 'test.docx';
$apiKey = *******;
$postdata = array('OutputFileName' => 'test.pdf', 'ApiKey' => $apiKey, 'File' => $fileToConvert);
$ch = curl_init("http://do.convertapi.com/Word2Pdf");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
$result = curl_exec($ch);
$headers = curl_getinfo($ch);
curl_close($ch);
var_dump($result);
我得到的结果如下:“HTTP / 1.1 100继续HTTP / 1.1 400'文件'参数不能为空。请设置值.Cache-Control:no-cache,no-store Pragma:no -cache Content-Type:text / html ...“
我在这里做错了什么?
答案 0 :(得分:0)
$response = Unirest::post(
"http://do.convertapi.com/Word2Pdf?ApiKey=<Your api key>",
array(
"File" => "@/tmp/file.path",
"OutputFormat" => "pdf",
)
);