2

我正在使用 Dropbox Core API + PHP。

我正在处理

https://api.dropbox.com/1/search/dropbox/

这可能是一个愚蠢的问题,但是当我取回 json 文件时,类似于

[
    {
        "size": "0 bytes",
        "rev": "35c1f029684fe",
        "thumb_exists": false,
        "bytes": 0,
        "modified": "Mon, 18 Jul 2011 20:13:43 +0000",
        "path": "/mypics/image1.jpg",
        "is_dir": false,
        "icon": "image1",
        "root": "dropbox",
        "mime_type": "jpg",
        "revision": 220191
    }
]

路径类似于“mypics/image1.jpg”:但绝对 url 是什么?如何在我的域中正确显示该图像?

4

3 回答 3

2

像这样在元数据中返回的路径,例如,从搜索、元数据、增量等调用中返回的路径是用户的 Dropbox 内的路径,而不是 Internet 可访问的 URL。

您可以将这些路径与有关文件的其他 API 调用一起使用,例如:

getFile:(这对于将文件内容下载到您的应用程序很有用) http://dropbox.github.io/dropbox-sdk-php/api-docs/v1.1.x/source-class-Dropbox.Client.html #131-185

createShareableLink:(这对于获取将文件共享给其他人的链接很有用) http://dropbox.github.io/dropbox-sdk-php/api-docs/v1.1.x/source-class-Dropbox.Client .html#962-993

createTemporaryDirectLink:(这对于获取临时直接链接很有用,例如,用于媒体播放器中的流式传输) http://dropbox.github.io/dropbox-sdk-php/api-docs/v1.1.x/source-类-Dropbox.Client.html#995-1024

于 2013-10-22T23:10:07.390 回答
0

首先,您将文件暂时从下拉框移动到您的目录,然后使用 img 标签您可以显示图像。

于 2013-12-28T11:28:04.010 回答
0

这是 Vito Tardia 的文章使用 PHP 访问 Dropbox 的源代码,可在http://sitepoint.com/access-dropbox-using-php获得

你可以试试这段代码

 require_once('bootstrap.php');

    $session = new DropboxSession(
    $config["dropbox"]["app_key"], 
    $config["dropbox"]["app_secret"], 
    $config["dropbox"]["access_type"], 
    $access_token
);
$client = new DropboxClient($session);
$path =  '/blank.png';
$outFile = "blank.png";

try {
    // Download the file to your server
    $file = $client->getFile($path, $outFile);
   } catch (\Dropbox\Exception\NotFoundException $e) {
    echo 'Error';
  }
于 2016-11-15T12:47:28.597 回答