我正在尝试使用WoT Dossier服务将档案转换为 JSON,在他们的FAQ中,他们显示了以下 cURL 示例:
curl --data-binary @dossier.dat http://wot-dossier.appspot.com/service/dossier-to-json
在为出了什么问题而挠头数小时后,我没有运气。这是我用来尝试复制命令的代码(PHP):
$url = "http://wot-dossier.appspot.com/service/dossier-to-json";
$file = realpath('dossier_temp/' . $full_fn);
echo $file;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/octet-stream"));
curl_setopt($ch, CURLOPT_POSTFIELDS, array("@$file"));
$curl_res = curl_exec($ch);
curl_close($ch);
$json = json_decode($curl_res, true);
Avar_dump()
的json显示为NULL,但这怎么可能呢?邮递区某处有错误吗?
任何帮助,将不胜感激