Dropbox API重定向循环 [英] Dropbox API Redirection Loop
问题描述
我正在使用Dropbox Core API提供的php SDK。我有一个小错误...即使单击允许按钮,我的文件也一直都在重定向...下面是我的索引文件:
index.php
<?php
session_start();
ini_set( display_errors,1);
require_once __DIR __。’/ dropbox-sdk / Dropbox / strict.php;
$ appInfoFile = __DIR __。 / AppInfo.json;
//注意:您应该使用Composer的全局自动加载器。但是,只要这些示例
//对没有Composer的用户起作用,我们将使用该库的 autoload.php。
require_once __DIR __。’/ dropbox-sdk / Dropbox / autoload.php’;
使用\Dropbox作为dbx;
$ requestPath = init();
echo请求路径=。$ requestPath。< br>;
if($ requestPath === /){
$ dbxClient = getClient();
if($ dbxClient === false){
echo Path: .getPath( dropbox-auth-start)。< br>; die;
header( Location: .getPath( dropbox-auth-start));
出口;
}
$ path = /; //调试完成
if(isset($ _ GET ['path']))$ path = $ _GET ['路径'];
$ entry = $ dbxClient-> getMetadataWithChildren($ path);
echo Client< pre>;
print_r($ dbxClient);
echo< / pre>;
echo Entry。$ entry; die;
if($ entry [’is_dir']){
echo renderFolder($ entry);
}
else {
echo renderFile($ entry);
}
}
else if($ requestPath == / download){
// die( Download);
$ dbxClient = getClient();
if($ dbxClient === false){
header( Location: .getPath( dropbox-auth-start));;
出口;
}
if(!isset($ _ GET [’path’])){
header( Location: .getPath()));
出口;
}
$ path = $ _GET [’path’];
$ fd = tmpfile();
$ metadata = $ dbxClient-> getFile($ path,$ fd);
标头( Content-Type:$ metadata [mime_type]);
fseek($ fd,0);
fpassthru($ fd);
fclose($ fd);
}
else if($ requestPath === / upload){
// die( Upload);
if(empty($ _ FILES ['file'] ['name'])){
echo renderHtmlPage( Error,请选择要上传的文件);
出口;
}
if(!empty($ _ FILES ['file'] ['error'])){
echo renderHtmlPage( Error, Error。$ _ FILES ['file'] ['error']。上传文件。请参见< a href ='http://php.net/manual/zh-cn/features.file-upload.errors.php'>文档< / a>以获取详细信息);
出口;
}
$ dbxClient = getClient();
$ remoteDir = /;
if(isset($ _ POST [’folder’]))$ remoteDir = $ _POST [’folder’];
$ remotePath = rtrim($ remoteDir, /\").\"/\".$_FILES['file']['name'];
$ fp = fopen($ _ FILES ['file'] ['tmp_name'], rb);
$ result = $ dbxClient-> uploadFile($ remotePath,dbx\WriteMode :: add(),$ fp);
fclose($ fp);
$ str = print_r($ result,TRUE);
echo renderHtmlPage(上传文件,结果:< pre> $ str< / pre>);
}
else if($ requestPath === / dropbox-auth-start){
// die( dropbox-auth-start);
$ authorizeUrl = getWebAuth()-> start();
header( Location:$ authorizeUrl);
}
else if($ requestPath === / dropbox-auth-finish){
// die( dropbox-auth-finish);
try {
list($ accessToken,$ userId,$ urlState)= getWebAuth()->完成($ _GET);
//我们没有传递$ urlState来完成操作,并且我们假设会话不能被
//篡改,因此应为null。
assert($ urlState === null);
}
catch(dbx\WebAuthException_BadRequest $ ex){
responseWithError(400, Bad Request);
//将完整的详细信息写入服务器错误日志。
//重要提示:切勿向用户显示$ ex-> getMessage()字符串-它可能包含
//敏感信息。
error_log( / dropbox-auth-finish:错误的请求:。$ ex-> getMessage());
出口;
}
catch(dbx\WebAuthException_BadState $ ex){
//身份验证会话已过期。重新启动身份验证过程。
header( Location: .getPath( dropbox-auth-start));
出口;
}
catch(dbx\WebAuthException_Csrf $ ex){
responseWithError(403,未经授权, CSRF不匹配);
//将完整的详细信息写入服务器错误日志。
//重要提示:请勿向用户显示$ ex-> getMessage()字符串-它包含
//敏感信息,可用于绕过CSRF检查。
error_log( / dropbox-auth-finish:CSRF不匹配:。$ ex-> getMessage());
出口;
}
catch(dbx\WebAuthException_NotApproved $ ex){
echo renderHtmlPage( Not Authorized?,为什么不呢?);
出口;
}
catch(dbx\WebAuthException_Provider $ ex){
error_log( / dropbox-auth-finish:未知错误:。$ ex-> getMessage());
responseWithError(500,内部服务器错误);
出口;
}
catch(dbx\Exception $ ex){
error_log( / dropbox-auth-finish:与Dropbox API通信时出错:。$ ex-> getMessage()) ;
responseWithError(500,内部服务器错误);
出口;
}
//注意:真正的Web应用程序会将访问令牌存储在数据库中。
$ _SESSION [’access-token’] = $ accessToken;
echo renderHtmlPage( Authorized!,
Auth complete,< a href ='。htmlspecialchars(getPath())。''>点击此处< / a> ;浏览。)
}
else if($ requestPath === / dropbox-auth-unlink){
// die( dropbox-auth-unlink);
//忘记访问令牌。
未设置($ _SESSION ['access-token']);
echo renderHtmlPage( Unlinked。,
返回< a href =’。htmlspecialchars(getPath())。’> home< / a> ;.);
}
else {
// die( else part);
echo renderHtmlPage( URL错误, $ requestPath没有处理程序);
出口;
}
函数renderFolder($ entry)
{
// TODO:添加令牌以抵抗CSRF攻击。
$ upload_path = htmlspecialchars(getPath(‘upload’));
$ path = htmlspecialchars($ entry [’path’]);
$ form =<< HTML
< form action ='$ upload_path'method ='post'enctype ='multipart / form-data'>
< label for ='file'>上传文件:< / label> <输入名称=文件类型=文件 />
<输入类型=提交值=上传 />
<输入名称=文件夹类型=隐藏值= $路径 />
< / form>
HTML;
$ listing =’;
foreach($ entry [contents]]为$ child){
$ cp = $ child ['path'];
$ cn = basename($ cp);
if($ child [’is_dir'])$ cn。=‘/’;
$ cp = htmlspecialchars($ cp);
$ link = getPath(?path =。htmlspecialchars($ cp));
$ listing。=< div>< a样式=’文字装饰:none’href ='$ link’> $ cn< / a>< / div>;
}
return renderHtmlPage( Folder:$ entry [path],$ form。$ listing);
}
函数getAppConfig()
{
global $ appInfoFile;
试试{
$ appInfo = dbx\AppInfo :: loadFromJsonFile($ appInfoFile);
}
catch(dbx\AppInfoLoadException $ ex){
抛出new Exception(无法加载\ $ appInfoFile\:。$ ex-> getMessage() );
}
$ clientIdentifier = examples-web-file-browser;
$ userLocale = null;
返回数组($ appInfo,$ clientIdentifier,$ userLocale);
}
函数getClient()
{
if(!isset($ _ SESSION [’access-token'])){
return false;
}
list($ appInfo,$ clientIdentifier,$ userLocale)= getAppConfig();
$ accessToken = $ _SESSION ['access-token'];
返回新的dbx\Client($ accessToken,$ clientIdentifier,$ userLocale,$ appInfo-> getHost());
}
函数getWebAuth()
{
list($ appInfo,$ clientIdentifier,$ userLocale)= getAppConfig();
$ redirectUri = http:// localhost / MyApi / Dropbox /; // success.php; // getUrl( dropbox-auth-finish);
$ csrfTokenStore =新的dbx\ \ArrayEntryStore($ _ SESSION,'dropbox-auth-csrf-token');
返回新的dbx\WebAuth($ appInfo,$ clientIdentifier,$ redirectUri,$ csrfTokenStore,$ userLocale);
}
函数renderFile($ entry)
{
$ metadataStr = htmlspecialchars(print_r($ entry,true));
$ downloadPath = getPath( download?path = .htmlspecialchars($ entry ['path']));
$ body =<< HTML
< pre> $ metadataStr< / pre>
< a href = $ downloadPath>下载此文件< / a>
HTML;
return renderHtmlPage( File:。$ entry ['path'],$ body);
}
函数renderHtmlPage($ title,$ body)
{
return<<< HTML
< html>
< ; head>
< title> $ title< / title>
< / head>
< body>
< h1> $ title< / h1>
$ body
< / body>
< / html>
HTML;
}
函数responseWithError($ code,$ title,$ body =)
{
$ proto = $ _SERVER [’SERVER_PROTOCOL’];
标头( $ proto $ code $ title,true,$ code);
echo renderHtmlPage($ title,$ body);
}
函数getUrl($ relative_path)
{
if(isset($ _ SERVER ['HTTPS'])&& $ _SERVER ['HTTPS' ]!=='off'){
$ scheme = https;
} else {
$ scheme = http;
}
$ host = $ _SERVER [’HTTP_HOST’];
$ path = getPath($ relative_path);
返回$ scheme。://。$ host。$ path;
}
函数getPath($ relative_path)
{
if(PHP_SAPI ==='cli-server'){
返回 /。 $ relative_path;
} else {
echo服务器值:< pre> ;;
print_r($ _ SERVER);
echo< / pre>;
返回$ _SERVER [ SCRIPT_NAME]。 /。$ relative_path;
}
}
函数init()
{
global $ argv;
//如果我们作为命令行脚本运行,请启动PHP内置Web服务器。
if(PHP_SAPI ===‘cli’){
launchBuiltInWebServer($ argv);
assert(false);
}
if(PHP_SAPI ==='cli-server'){
//对于当我们在PHP的内置Web服务器下运行时,请在此处进行路由。
返回$ _SERVER ['SCRIPT_NAME'];
}
else {
//用于当我们在CGI或mod_php下运行时。
if(isset($ _ SERVER ['PATH_INFO'])){
返回$ _SERVER ['PATH_INFO'];
}否则{
返回 /;
}
}
}
函数launchBuiltInWebServer($ argv)
{
//内置Web服务器仅在PHP 5.4以上。
if(version_compare(PHP_VERSION,'5.4.0','<')){
fprintf(STDERR,
无法运行示例。您用来运行此版本的PHP版本脚本( .PHP_VERSION。)\n。
没有内置的Web服务器。您需要PHP 5.4或更高版本。\n。
\n 。
如果您的Web服务器支持PHP 5.3.\n,您仍然可以运行此示例。
将Dropbox PHP SDK复制到您的Web服务器的文档路径中并在其中访问。\ \n);
出口(2);
}
$ php_file = $ argv [0];
if(count($ argv)=== 1){
$ port = 5000;
}否则,如果(count($ argv)=== 2){
$ port = intval($ argv [1]);
} else {
fprintf(STDERR,
参数过多。\n。
用法:php $ argv [0] [服务器端口] \n );
出口(1);
}
$ host = localhost:$ port;
$ cmd = escapeshellarg(PHP_BINARY)。 -S。$ host。 .escapeshellarg($ php_file);
$ descriptors = array(
0 => array( pipe, r),//处理'stdin。我们将立即关闭它。
1 => ; STDOUT,//将进程的stderr传递到我们的
2 => STDERR,//将进程的stderr传递到我们的
);
$ proc = proc_open($ cmd,$ descriptor,$ pipes);
if($ proc === false){
fprintf(STDERR,
无法启动PHP的内置Web服务器。使用的命令:\n。
$ cmd\n);
出口(2);
}
fclose($ pipes [0]); //关闭进程的标准输入。
$ exitCode = proc_close($ proc); //等待进程退出。
exit($ exitCode);
}
?>
仅供参考:在我的保管箱应用程序中,我将重定向uri设置为: localhost / MyApi / Dropbox / ...但这就像循环……任何人都可以解决这个问题吗?我想将重定向uri更改为success.php,但是还有其他方法可以解决此问题吗?
更新:
我还粘贴了success.php文件:
success.php
<?php
session_start();
ini_set( display_errors,1);
#包括Dropbox SDK库
require_once dropbox-sdk / Dropbox / autoload.php;
使用\Dropbox作为dbx;
$ dbxClient =新的dbx\Client($ _ SESSION ['access-token'], PHP-PicPixa / 1.0); //此行给出错误
$ accountInfo = $ dbxClient-> getAccountInfo();
echo帐户信息:< pre> ;;
print_r($ accountInfo);
echo< / pre>;
$ f = fopen( working-draft.txt, a);
$ result = $ dbxClient-> uploadFile( / working-draft.txt,dbx\WriteMode :: add(),$ f);
fclose($ f);
print_r($ result);
$ folderMetadata = $ dbxClient-> getMetadataWithChildren( /);
print_r($ folderMetadata);
$ f = fopen( working-draft.txt, w + b);
$ fileMetadata = $ dbxClient-> getFile( / working-draft.txt,$ f);
fclose($ f);
echo< br>文件元数据:< br>< pre>;
print_r($ fileMetadata);
echo< / pre>;
?>
要访问我的完整项目,请从以下地址下载它: https://www.dropbox.com/sh/ps90blb2uujbxxh/AABdbU39upJSOeiLwxSnjufFa
b谢谢
看起来您注释掉了将重定向到 dropbox-auth-的代码完成
。由于您永远不会去那里,所以您永远不会完成身份验证过程,也不会将 $ _ SESSION ['access-token']
设置为任何内容。
I am using php sdk provided by Dropbox Core API. I have a minor bug... My file is being redirected all the time even I click on the allow button... Below is my index file:
index.php
<?php
session_start();
ini_set("display_errors",1);
require_once __DIR__.'/dropbox-sdk/Dropbox/strict.php';
$appInfoFile = __DIR__."/AppInfo.json";
// NOTE: You should be using Composer's global autoloader. But just so these examples
// work for people who don't have Composer, we'll use the library's "autoload.php".
require_once __DIR__.'/dropbox-sdk/Dropbox/autoload.php';
use \Dropbox as dbx;
$requestPath = init();
echo "Request path = ".$requestPath."<br>";
if ($requestPath === "/") {
$dbxClient = getClient();
if ($dbxClient === false) {
echo "Path: ".getPath("dropbox-auth-start")."<br>";die;
header("Location: ".getPath("dropbox-auth-start"));
exit;
}
$path = "/";//Debug completed
if (isset($_GET['path'])) $path = $_GET['path'];
$entry = $dbxClient->getMetadataWithChildren($path);
echo "Client<pre>";
print_r($dbxClient);
echo "</pre>";
echo "Entry".$entry;die;
if ($entry['is_dir']) {
echo renderFolder($entry);
}
else {
echo renderFile($entry);
}
}
else if ($requestPath == "/download") {
//die("Download");
$dbxClient = getClient();
if ($dbxClient === false) {
header("Location: ".getPath("dropbox-auth-start"));
exit;
}
if (!isset($_GET['path'])) {
header("Location: ".getPath(""));
exit;
}
$path = $_GET['path'];
$fd = tmpfile();
$metadata = $dbxClient->getFile($path, $fd);
header("Content-Type: $metadata[mime_type]");
fseek($fd, 0);
fpassthru($fd);
fclose($fd);
}
else if ($requestPath === "/upload") {
//die("Upload");
if (empty($_FILES['file']['name'])) {
echo renderHtmlPage("Error", "Please choose a file to upload");
exit;
}
if (!empty($_FILES['file']['error'])) {
echo renderHtmlPage("Error", "Error ".$_FILES['file']['error']." uploading file. See <a href='http://php.net/manual/en/features.file-upload.errors.php'>the docs</a> for details");
exit;
}
$dbxClient = getClient();
$remoteDir = "/";
if (isset($_POST['folder'])) $remoteDir = $_POST['folder'];
$remotePath = rtrim($remoteDir, "/")."/".$_FILES['file']['name'];
$fp = fopen($_FILES['file']['tmp_name'], "rb");
$result = $dbxClient->uploadFile($remotePath, dbx\WriteMode::add(), $fp);
fclose($fp);
$str = print_r($result, TRUE);
echo renderHtmlPage("Uploading File", "Result: <pre>$str</pre>");
}
else if ($requestPath === "/dropbox-auth-start") {
//die("dropbox-auth-start");
$authorizeUrl = getWebAuth()->start();
header("Location: $authorizeUrl");
}
else if ($requestPath === "/dropbox-auth-finish") {
//die("dropbox-auth-finish");
try {
list($accessToken, $userId, $urlState) = getWebAuth()->finish($_GET);
// We didn't pass in $urlState to finish, and we're assuming the session can't be
// tampered with, so this should be null.
assert($urlState === null);
}
catch (dbx\WebAuthException_BadRequest $ex) {
respondWithError(400, "Bad Request");
// Write full details to server error log.
// IMPORTANT: Never show the $ex->getMessage() string to the user -- it could contain
// sensitive information.
error_log("/dropbox-auth-finish: bad request: " . $ex->getMessage());
exit;
}
catch (dbx\WebAuthException_BadState $ex) {
// Auth session expired. Restart the auth process.
header("Location: ".getPath("dropbox-auth-start"));
exit;
}
catch (dbx\WebAuthException_Csrf $ex) {
respondWithError(403, "Unauthorized", "CSRF mismatch");
// Write full details to server error log.
// IMPORTANT: Never show the $ex->getMessage() string to the user -- it contains
// sensitive information that could be used to bypass the CSRF check.
error_log("/dropbox-auth-finish: CSRF mismatch: " . $ex->getMessage());
exit;
}
catch (dbx\WebAuthException_NotApproved $ex) {
echo renderHtmlPage("Not Authorized?", "Why not?");
exit;
}
catch (dbx\WebAuthException_Provider $ex) {
error_log("/dropbox-auth-finish: unknown error: " . $ex->getMessage());
respondWithError(500, "Internal Server Error");
exit;
}
catch (dbx\Exception $ex) {
error_log("/dropbox-auth-finish: error communicating with Dropbox API: " . $ex->getMessage());
respondWithError(500, "Internal Server Error");
exit;
}
// NOTE: A real web app would store the access token in a database.
$_SESSION['access-token'] = $accessToken;
echo renderHtmlPage("Authorized!",
"Auth complete, <a href='".htmlspecialchars(getPath(""))."'>click here</a> to browse.");
}
else if ($requestPath === "/dropbox-auth-unlink") {
//die("dropbox-auth-unlink");
// "Forget" the access token.
unset($_SESSION['access-token']);
echo renderHtmlPage("Unlinked.",
"Go back <a href='".htmlspecialchars(getPath(""))."'>home</a>.");
}
else {
//die("else part");
echo renderHtmlPage("Bad URL", "No handler for $requestPath");
exit;
}
function renderFolder($entry)
{
// TODO: Add a token to counter CSRF attacks.
$upload_path = htmlspecialchars(getPath('upload'));
$path = htmlspecialchars($entry['path']);
$form = <<<HTML
<form action='$upload_path' method='post' enctype='multipart/form-data'>
<label for='file'>Upload file:</label> <input name='file' type='file'/>
<input type='submit' value='Upload'/>
<input name='folder' type='hidden' value='$path'/>
</form>
HTML;
$listing = '';
foreach($entry['contents'] as $child) {
$cp = $child['path'];
$cn = basename($cp);
if ($child['is_dir']) $cn .= '/';
$cp = htmlspecialchars($cp);
$link = getPath("?path=".htmlspecialchars($cp));
$listing .= "<div><a style='text-decoration: none' href='$link'>$cn</a></div>";
}
return renderHtmlPage("Folder: $entry[path]", $form.$listing);
}
function getAppConfig()
{
global $appInfoFile;
try {
$appInfo = dbx\AppInfo::loadFromJsonFile($appInfoFile);
}
catch (dbx\AppInfoLoadException $ex) {
throw new Exception("Unable to load \"$appInfoFile\": " . $ex->getMessage());
}
$clientIdentifier = "examples-web-file-browser";
$userLocale = null;
return array($appInfo, $clientIdentifier, $userLocale);
}
function getClient()
{
if(!isset($_SESSION['access-token'])) {
return false;
}
list($appInfo, $clientIdentifier, $userLocale) = getAppConfig();
$accessToken = $_SESSION['access-token'];
return new dbx\Client($accessToken, $clientIdentifier, $userLocale, $appInfo->getHost());
}
function getWebAuth()
{
list($appInfo, $clientIdentifier, $userLocale) = getAppConfig();
$redirectUri = "http://localhost/MyApi/Dropbox/";//success.php";//getUrl("dropbox-auth-finish");
$csrfTokenStore = new dbx\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token');
return new dbx\WebAuth($appInfo, $clientIdentifier, $redirectUri, $csrfTokenStore, $userLocale);
}
function renderFile($entry)
{
$metadataStr = htmlspecialchars(print_r($entry, true));
$downloadPath = getPath("download?path=".htmlspecialchars($entry['path']));
$body = <<<HTML
<pre>$metadataStr</pre>
<a href="$downloadPath">Download this file</a>
HTML;
return renderHtmlPage("File: ".$entry['path'], $body);
}
function renderHtmlPage($title, $body)
{
return <<<HTML
<html>
<head>
<title>$title</title>
</head>
<body>
<h1>$title</h1>
$body
</body>
</html>
HTML;
}
function respondWithError($code, $title, $body = "")
{
$proto = $_SERVER['SERVER_PROTOCOL'];
header("$proto $code $title", true, $code);
echo renderHtmlPage($title, $body);
}
function getUrl($relative_path)
{
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') {
$scheme = "https";
} else {
$scheme = "http";
}
$host = $_SERVER['HTTP_HOST'];
$path = getPath($relative_path);
return $scheme."://".$host.$path;
}
function getPath($relative_path)
{
if (PHP_SAPI === 'cli-server') {
return "/".$relative_path;
} else {
echo "Server values:<pre>";
print_r($_SERVER);
echo "</pre>";
return $_SERVER["SCRIPT_NAME"]."/".$relative_path;
}
}
function init()
{
global $argv;
// If we were run as a command-line script, launch the PHP built-in web server.
if (PHP_SAPI === 'cli') {
launchBuiltInWebServer($argv);
assert(false);
}
if (PHP_SAPI === 'cli-server') {
// For when we're running under PHP's built-in web server, do the routing here.
return $_SERVER['SCRIPT_NAME'];
}
else {
// For when we're running under CGI or mod_php.
if (isset($_SERVER['PATH_INFO'])) {
return $_SERVER['PATH_INFO'];
} else {
return "/";
}
}
}
function launchBuiltInWebServer($argv)
{
// The built-in web server is only available in PHP 5.4+.
if (version_compare(PHP_VERSION, '5.4.0', '<')) {
fprintf(STDERR,
"Unable to run example. The version of PHP you used to run this script (".PHP_VERSION.")\n".
"doesn't have a built-in web server. You need PHP 5.4 or newer.\n".
"\n".
"You can still run this example if you have a web server that supports PHP 5.3.\n".
"Copy the Dropbox PHP SDK into your web server's document path and access it there.\n");
exit(2);
}
$php_file = $argv[0];
if (count($argv) === 1) {
$port = 5000;
} else if (count($argv) === 2) {
$port = intval($argv[1]);
} else {
fprintf(STDERR,
"Too many arguments.\n".
"Usage: php $argv[0] [server-port]\n");
exit(1);
}
$host = "localhost:$port";
$cmd = escapeshellarg(PHP_BINARY)." -S ".$host." ".escapeshellarg($php_file);
$descriptors = array(
0 => array("pipe", "r"), // Process' stdin. We'll just close this right away.
1 => STDOUT, // Relay process' stdout to ours.
2 => STDERR, // Relay process' stderr to ours.
);
$proc = proc_open($cmd, $descriptors, $pipes);
if ($proc === false) {
fprintf(STDERR,
"Unable to launch PHP's built-in web server. Used command:\n".
" $cmd\n");
exit(2);
}
fclose($pipes[0]); // Close the process' stdin.
$exitCode = proc_close($proc); // Wait for process to exit.
exit($exitCode);
}
?>
FYI: in my dropbox app I have set the redirect uri as : "localhost/MyApi/Dropbox/"... But it is going like loop... Can any one solve this? I thought to change the redirect uri to success.php but is there any other way to solve this?
Update:
I am also pasting my success.php file:
success.php
<?php
session_start();
ini_set("display_errors",1);
# Include the Dropbox SDK libraries
require_once "dropbox-sdk/Dropbox/autoload.php";
use \Dropbox as dbx;
$dbxClient = new dbx\Client($_SESSION['access-token'], "PHP-PicPixa/1.0");//This line is giving error
$accountInfo = $dbxClient->getAccountInfo();
echo "Account Info:<pre>";
print_r($accountInfo);
echo "</pre>";
$f = fopen("working-draft.txt", "a");
$result = $dbxClient->uploadFile("/working-draft.txt", dbx\WriteMode::add(), $f);
fclose($f);
print_r($result);
$folderMetadata = $dbxClient->getMetadataWithChildren("/");
print_r($folderMetadata);
$f = fopen("working-draft.txt", "w+b");
$fileMetadata = $dbxClient->getFile("/working-draft.txt", $f);
fclose($f);
echo "<br>File meta data:<br><pre>";
print_r($fileMetadata);
echo "</pre>";
?>
To access my full project please download it from: https://www.dropbox.com/sh/ps90blb2uujbxxh/AABdbU39upJSOeiLwxSnjufFa
Thank You,
It looks like you commented out code that would have redirected to dropbox-auth-finish
. Since you're never going there, you're never finishing the auth process and never setting $_SESSION['access-token']
to anything.
这篇关于Dropbox API重定向循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!