Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从dropbox下载文件?_Php_Dropbox - Fatal编程技术网

Php 从dropbox下载文件?

Php 从dropbox下载文件?,php,dropbox,Php,Dropbox,我想通过php从我的dropbox下载一个csv文件到我的服务器 我尝试使用Dropbox API,但没有得到积极的结果。我下载了dropbox,将其安装在我的服务器上,并使用了以下示例之一: <?php # Include the Dropbox SDK libraries require_once "dropbox-sdk/Dropbox/autoload.php"; use \Dropbox as dbx; $appInfo = dbx\AppInfo::loadFromJson

我想通过php从我的dropbox下载一个csv文件到我的服务器

我尝试使用Dropbox API,但没有得到积极的结果。我下载了dropbox,将其安装在我的服务器上,并使用了以下示例之一:

<?php

# Include the Dropbox SDK libraries
require_once "dropbox-sdk/Dropbox/autoload.php";
use \Dropbox as dbx;

$appInfo = dbx\AppInfo::loadFromJsonFile("app-info.json");
$webAuth = new dbx\WebAuthNoRedirect($appInfo, "PHP-Example/1.0");

$authorizeUrl = $webAuth->start();

$authCode = \trim(\readline("the_authentication_code_from_dropbox"));

list($accessToken, $dropboxUserId) = $webAuth->finish($authCode);
print "Access Token: " . $accessToken . "\n";

$f = fopen("working-draft.txt", "w+b");
$fileMetadata = $dbxClient->getFile("/working-draft.txt", $f);
fclose($f);
print_r($fileMetadata);

?>


但此代码无法检索我的文件:(请提供任何帮助:)

您知道,您并没有将身份验证代码替换为“来自dropbox的身份验证代码”部分,因为启用readline时,php会切换终端模式以接受行缓冲输入,因此您必须通过终端写入代码,或者将整个语句替换为
$authCode=“代码”?另外,您是否尝试过使用
$accountInfo=$dbxClient->getAccountInfo()以测试我们是否已按照文档中的建议访问了核心API?最后,您确定您的dropbox中存在一个名为working-draft.txt的文件吗?不,Jonast92,我不知道。我会试试的。如果可行的话,我会把它贴出来作为答案。所以我按照你的建议做了,但同样没有运气。我已经打印了一个数组,其中包含所有允许的文件扩展名,但没有发生其他事情。每次我想再试一次,我都必须重新输入身份验证代码。