我在尝试使用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