我试图使用php中的cURL将文件放入dropbox rest api。
https://www.dropbox.com/developers/core/docs#files_put
这是我的代码
$token = '-';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api-content.dropbox.com/1/files_put/auto/test.txt?overwrite=true&access_token=" . $token);
//curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token));
curl_setopt($ch, CURLOPT_POSTFIELDS,
http_build_query(array('postvar1' => 'value1')));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
if ($server_output == "OK") {
echo "hi";
} else {
echo "nein";
}
但由于某些原因,这不起作用。任何帮助将不胜感激。