2
好吧...我無法弄清楚的新手問題。下面介紹一下Box.com documentation說,對上傳文件:cURL到PHP的翻譯問題
curl https://upload.box.com/api/2.0/files/content \
-H "Authorization: Bearer ACCESS_TOKEN" -X POST \
-F attributes='{"name":"tigers.jpeg", "parent":{"id":"11446498"}}' \
-F [email protected]
我在PHP嘗試此:
$attributes='{"name":"tigers.jpeg", "parent":{"id":"4224475591"}}';
$headr = array();
$headr[] = 'Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxx';
$prep_data = array('file'=>'data08.13.15.csv','attributes' => $attributes);
$post_data= http_build_query($prep_data) . "\n";
$url = 'https://upload.box.com/api/2.0/files/content';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER,$headr);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
var_dump($response);
我得到string(0) ""
回我var_dump($response);
我在做什麼錯這裏?