无法将文件上传到BOX api

时间:2016-04-15 13:16:30

标签: php box-api

我写了这段代码。我将数据发送到$url = "https://upload.box.com/api/2.0/files/content",但我没有收到回复。也许有人也遇到过这个问题?

 $absolutePath = 'home/my/path/uploads/media/ClientPDF/0001/01/c607bea86bdb42220bb49aac722b4a5eb44be3db.pdf';

 $json = json_encode([
      'name'   => 'c607bea86bdb42220bb49aac722b4a5eb44be3db.pdf,
      'parent' => ['id' => 7479666489] //parent folder
 ]);

 $fields = [
     'attributes' => $json,
     'file'       => @$absolutePath
 ];

 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, $url);
 curl_setopt($ch, CURLOPT_HTTPHEADER, [
                   'Authorization: Bearer MY_TOKEN_KEY'
                   'Content-Type:multipart/form-data'
 ]);
 curl_setopt($ch, CURLOPT_POST, true);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
 $response = curl_exec($ch);
 var_dump(json_decode($response, true)); die;

var_dump - 什么都不打印,我无法调试此请求。请帮我解决这个问题

0 个答案:

没有答案