在php中上传box api的文件方法的新版本不起作用
这是我用来发送请求的代码
$uploadfile =$_SESSION['uploadfile'];
$fileid =$_SESSION['fileid'];
$myuri='https://upload.box.com/api/2.0/files/'.$fileid.'/content';
$curl2 = curl_init();
curl_setopt($curl2, CURLOPT_HTTPHEADER, array('Authorization: Bearer '.$_SESSION['usertoken']));
curl_setopt_array($curl2, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $myuri,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => array(
filename => "@".$uploadfile
)
));
// Send the request & save response to $resp
$data = curl_exec($curl2);
$data = json_decode($data);
我从框中收到以下错误响应:
object(stdClass)#1 (7) { ["type"]=> string(5) "error" ["status"]=> int(400) ["code"]=> string(11) "bad_request" ["context_info"]=> object(stdClass)#2 (1) { ["errors"]=> array(1) { [0]=> object(stdClass)#3 (3) { ["reason"]=> string(17) "missing_parameter" ["name"]=> string(6) "parent" ["message"]=> string(20) "'parent' is required" } } } ["help_url"]=> string(38) "http://developers.box.com/docs/#errors" ["message"]=> string(11) "Bad Request" ["request_id"]=> string(23) "1638286030525d1c87c6a1e" }
根据他们的文档,我只需要我要上传的文件的文件名和我要覆盖的文件的文件 ID,它没有说明需要父母我在这里缺少什么?这是一个错误还是文档错误?
可以在此处找到文档http://developers.box.com/docs/#files-upload-a-new-version-of-a-file