我在嘗試使用PHP和Dropbox API上載文件時遇到問題。當cURL執行時,我得到一個頁面未找到錯誤。這表明一個URL的問題,但我不明白這是錯的。PHP Dropbox API - 未找到頁面使用files_put發生錯誤
該文件存在且所有OAuth都在工作。
截圖錯誤:
這是在代碼中使用了 - 我失去了一些東西在這裏?
$filePathName = "/path_to_file/my_image.png";
$url = "https://api-content.dropbox.com/1/files_put/sandbox/my_folder/my_image.png";
$headers = array("Content-Type: ".mime_content_type($filePathName)."\r\nContent-Length: ".filesize($filePathName)."\r\n".
"Authorization: OAuth oauth_version=\"1.0\", oauth_signature_method=\"PLAINTEXT\", oauth_consumer_key=\"".DROPBOX_APP_KEY."\", oauth_token=\"".DROPBOX_OAUTH_ACCESS_TOKEN."\", oauth_signature=\"".DROPBOX_APP_SECRET."&".DROPBOX_OAUTH_ACCESS_SECRET."\""
);
$fh = fopen($filePathName, "rb");
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_PUT, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($ch, CURLOPT_INFILE, $fh);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($filePathName));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$apiResponse = curl_exec($ch);
fclose($fh);
die("Response:<br />".$apiResponse);
謝謝貝司。我已經在使用該頁面進行參考。我在我放在這裏的代碼示例(oops!)中犯了一個錯字,並且錯過了根值(這是沙箱)。我將編輯原文。 – TechyGypo 2013-04-25 08:40:55