2

I'm using Dropbox Core API + PHP.

I'm dealing with

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

It may be a silly question, but when i get back the json file, similar to

[
    {
        "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
    }
]

The path is something like "mypics/image1.jpg": but what's the absolute url? How can i display that image correctly in my domain?

Francesco
  • 24,839
  • 29
  • 105
  • 152
  • Please provide more information. Which API method are you using, what code are you working with, what is the full response dataset.... – Axel Oct 22 '13 at 14:44
  • sorry, you are right! I updated it. CoreAPI+PHP, method search. – Francesco Oct 22 '13 at 14:46
  • 1
    Just FYI. Dropbox doesn't like people hotlinking to the files. I believe if you were to retrieve an absolute JPG url, it would expire after a few hours anyways. You should really download the contents to your local server using the `/files (GET)` method, then serve it from your own server. If you need a direct link to the file, try the `createTemporaryDirectLink()` function documented here: http://dropbox.github.io/dropbox-sdk-php/api-docs/v1.1.x/source-class-Dropbox.Client.html#995-1024 – Axel Oct 22 '13 at 14:58
  • thank you. Dropbox documentations i very confusing. I understand your approach...I will try that.. – Francesco Oct 22 '13 at 17:50
  • $filelink = $dropbox->GetLink($o, false);?> – Hiren Raiyani Dec 28 '13 at 11:31

3 Answers3

2

The path returned in metadata like this, e.g., from the search, metadata, delta, etc calls, is the path inside the user's Dropbox, and not an Internet accessible URL.

You can use these paths with other API calls regarding files, for example:

getFile: (this is good for downloading the file content to your app) http://dropbox.github.io/dropbox-sdk-php/api-docs/v1.1.x/source-class-Dropbox.Client.html#131-185

createShareableLink: (this is good for getting a link to share the file to others) http://dropbox.github.io/dropbox-sdk-php/api-docs/v1.1.x/source-class-Dropbox.Client.html#962-993

createTemporaryDirectLink: (this is good for getting a temporary direct link, e.g., for streaming in a media player) http://dropbox.github.io/dropbox-sdk-php/api-docs/v1.1.x/source-class-Dropbox.Client.html#995-1024

Greg
  • 16,359
  • 2
  • 34
  • 44
0

First you move file temporarily from drop box to your directory and then using img tag u can display the image.

Hiren Raiyani
  • 754
  • 2
  • 12
  • 28
0

This is the source code for the article Access Dropbox Using PHP by Vito Tardia available at http://sitepoint.com/access-dropbox-using-php

You can try this code

 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';
  }
KHALID
  • 87
  • 7