我正在尝试在php(https://www.dropbox.com/developers-v1/core/start/php)中使用Dropbox核心API但是在运行以下代码解决方案时遇到堆栈溢出问题我被卡住了
<?php
require_once "dropbox-php-sdk-1.1.6/lib/Dropbox/autoload.php";
use \Dropbox as dbx;
$dropbox_config = array(
'key' => 'your_key',
'secret' => 'your_secret'
);
$appInfo = dbx\AppInfo::loadFromJson($dropbox_config);
$webAuth = new dbx\WebAuthNoRedirect($appInfo, "PHP-Example/1.0");
$authorizeUrl = $webAuth->start();
echo "1. Go to: " . $authorizeUrl . "<br>";
echo "2. Click \"Allow\" (you might have to log in first).<br>";
echo "3. Copy the authorization code and insert it into $authCode.<br>";
$authCode = trim('DjsR-iGv4PAAAAAAAAAAAbn9snrWyk9Sqrr2vsdAOm0');
list($accessToken, $dropboxUserId) = $webAuth->finish($authCode);
echo "Access Token: " . $accessToken . "<br>";
$dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0");
// Uploading the file
$f = fopen("working-draft.txt", "rb");
$result = $dbxClient->uploadFile("/working-draft.txt", dbx\WriteMode::add(), $f);
fclose($f);
print_r($result);
// Get file info
$file = $dbxClient->getMetadata('/working-draft.txt');
// sending the direct link:
$dropboxPath = $file['path'];
$pathError = dbx\Path::findError($dropboxPath);
if ($pathError !== null) {
fwrite(STDERR, "Invalid <dropbox-path>: $pathError\n");
die;
}
// The $link is an array!
$link = $dbxClient->createTemporaryDirectLink($dropboxPath);
// adding ?dl=1 to the link will force the file to be downloaded by the client.
$dw_link = $link[0]."?dl=1";
echo "Download link: ".$dw_link."<br>";
?>
当我运行此代码时出现此错误
我正在评论Dropbox核心API中的一些代码 dropbox-php-sdk-1.1.6 / lib / Dropbox / RequestUtil.php在5.6 php版本中运行dropbox core API
if (strlen((string) PHP_INT_MAX) < 19) {
// Looks like we're running on a 32-bit build of PHP. This could cause problems because some of the numbers
// we use (file sizes, quota, etc) can be larger than 32-bit ints can handle.
throw new \Exception("The Dropbox SDK uses 64-bit integers, but it looks like we're running on a version of PHP that doesn't support 64-bit integers (PHP_INT_MAX=" . ((string) PHP_INT_MAX) . "). Library: \"" . __FILE__ . "\"");
}
答案 0 :(得分:4)
2017年9月28日,Dropbox v1 API has been shutdown。您尝试使用的库是针对这个已退役的v1。
您应该使用其中一个v2 PHP libraries代替:
答案 1 :(得分:0)
仅供参考,API v1正在停用,因此该消息将返回400错误:{“error”:“v1_retired”}。这意味着您依赖API v1端点的工作/代码可能会停止工作。
我认为您尚未迁移到v2,请查看迁移指南以获取更多详细信息。
https://www.dropbox.com/developers/reference/migration-guide