1
我尝试使用他们的API和PHP将文件上传到DropBox。 多数民众赞成代码:使用Dropbox API超时错误上传文件
require_once "dropbox/lib/Dropbox/autoload.php";
use \Dropbox as dbx;
$appInfo = dbx\AppInfo::loadFromJsonFile("app_info.json");
$csrfTokenStore = new dbx\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token');
$webAuth = new dbx\WebAuth($appInfo, "NoteBoxApp/0.01", "http://localhost/notes", $csrfTokenStore, null);
$title=$_POST["titulo"].".txt";
$nota=$_POST["conteudo"];
$accessToken=$_SESSION["token"];
$clientIdentifier=$_SESSION["userId"];
$client= new dbx\Client($accessToken, $clientIdentifier);
$file = fopen($title, "w") or die("Unable to open file!");
fwrite($file, $nota);
$stat = fstat($file);
$size = (int) $stat['size'];
$dropboxPath="/Aplicativos/Notes01";
try{
$metadata = $client->uploadFile($dropboxPath, dbx\WriteMode::add(), $file, $size);
}
catch(Exception $e) {
echo "Exceção: ", $e->getMessage(), "\n";
}
fclose($file);
我总是异常
执行错误的HTTP请求:操作速度太慢。小于1024 字节/秒转移最后10秒
我看不出为什么!我在本地主机上使用XAMPP!... 在此先感谢您的帮助!