fabi.me

DropPHP – einfacher PHP Dropbox API Client ohne cURL

DropPHP ist eine kompakte PHP Klasse, die eine einfache Schnittstelle zur Dropbox REST API zur Verfügung stellt. Sie bietet Funktionen zum Auflisten, Hoch- und Runterladen von Dateien an ChangeDiva. DropPHP verwendet für HTTPS-Requests die in PHP eingebauten Stream-Wrapper, daher werden keine besonderen PHP Bilbiotheken wie PECL oder cURL benötigt Download FoxPlayer. Es steht unter einer BSD-Lizenz zur Verfügung, hier die GitHub Seite.

DropPHP
DropPHP
master.zip.html
Version: 1.4
12 KiB
16055 Downloads
Details

Funktionen

Die Klasse DropboxClient enthält folgende Funktionen 쯔바이. Bei einem Fehler wird eine DropboxException ausgeworfen, achte daher darauf, dass du die Funktionen in einem try-catch-Block aufrufst! Funktionen dropbox_file/dropbox_path als Parameter haben, akzeptieren diesen als string oder Metadata-Objekt der Datei oder des Ordners Download Internet Explorer 11 file.

GetAccountInfo() Ermittelt Informationen über den Benutzeraccount und gibt sie als Objekt zurück lg intelligent update 다운로드.
GetMetadata($dropbox_path) Ermittelt Metadaten einer Datei oder eines Ordners Download the New People Bible.
GetFiles($dropbox_path=”, $recursive=false)  Listet Dateien in einem Verzeichnis auf. Ist $recursive = true, werden Unterverzeichnisse rekursiv gelistet 산타나. Da jedes Verzeichnis eine neue Anfrage erfordert, kann das einige Zeit daueren!
DownloadFile($dropbox_file, $dest_path=”, $revision=-1)  Lädt eine Datei aus der Dropbox auf den Webserver certificate form. $dest_path gibt an, wo die Datei gespeichert wird (Zeilverzeichnis muss existieren). Mit $revision kann die Revision der Datei angegeben werden.
UploadFile($src_file, $dropbox_path=”)  Lädt eine Datei vom Webserver in die Dropbox Naver Calendar pc. Beachte, dass nur Dateien bis zu einer Größe von 150MB hochgeladen werden können!
GetLink($dropbox_file, $preview=true)  Gibt einen Link zu einer Dropbox-Datei zurück, mit dem jeder die Datei herunterladen kann windows xp iso 한글 다운로드. $preview gibt an, ob der Link auf eine Vorschauseite geht, anstatt direkt auf die Datei.
Delta($cursor)  Retrieves file changes. See delta
Copy($from_path, $to_path)  Copies a file or folder to a new location.
CreateFolder($path)  Creates a folder.
Delete($path)  Deletes a file or folder.
Move($from_path, $to_path)  Moves a file or folder to a new location.

Weitere Funktionen befinden sich in Entwicklung!

Authentifizierung

Die Dropbox API verwendet OAuth zur authentifizierung. Beim ersten Zugriff auf die Dropbox sendet der Dropbox server ein Request-Token. Der Benutzer wird zu einer Dropbox-Seite umgeleitet, wo er den Zugriff bestätigt. Anschließend wird mit dem gespeicherten Request-Token ein Access-Token ermittelt und gespeichert. Mit diesem lassen sich dann alle weiteren API-Anfragen authentifizieren.

DropPHP
DropPHP
master.zip.html
Version: 1.4
12 KiB
16055 Downloads
Details
Rating: 4.0/5. From 24 votes.
Please wait...
Voting is currently disabled, data maintenance in progress.

Verwandte Artikel

Kommentare

  • Arpit Goyal sagt:

    hi,
    we are students from IIT-Delhi, we used your source to authorise a user’s dropbox, it worked fine.
    But when we are adding new function for creating folder on user’s account then it’s giving an error,
    [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
    in /home/edciitd/public_html/handa/DropboxClient.php on line 293

    So can you notify us by mail as soon as possible, as we are competing in a hack competion of 24hrs, so we kind of need its solution fast.

  • Fabi sagt:

    Hi,
    to create a new folder, this should work (not tested):
    $this->apiCall(“fileops/create_folder”, “POST”, array(‘root’ => , ‘path’ => ));

    If you still get an error, you should debug print the $url passed to file_get_contents in the apiCall function.

    Regards
    Fabian

  • Mell sagt:

    Hi,
    How can i delete file from dropbox (using one folder access) with PHP Client?

    regards

  • Partha sagt:

    Sir,

    I want to download file directly in user pc, i was trying GetLink function it is not working.

    please help me

  • Mary sagt:

    Hi,

    I tried running the sample.php file and it redirects me to dropbox and authenticates but then I get a request token not found error. I don’t know why this is because I assumed the $request_token = load_token($_GET[‚oauth_token‘]); line would retrieve the token using GET.I don’t know if I have to add in something extra for the token to be found?

  • Fabi sagt:

    Hello Mary,
    the functions store_token and load_token are only for demonstration. If you want to use them you have to make sure the folder “tokens” exists and chmod it to 777.

  • sabana sagt:

    Hello,

    I used ur code and it worked fine. I want to create folder on dropbox in my app folder i coded the following

    function CreateFolder($dropbox_path)
    {
    return $this->apiCall(“fileops/create_folder/$this->rootPath/$dropbox_path”, “POST”);
    }

    function apiCall($path, $method, $params=array())
    {
    $url = $this->cleanUrl(self::API_URL.$path);
    $content = http_build_query(array_merge(array(‘locale’=>$this->locale), $params));
    $context = $this->createRequestContext($url, $method, $content);
    return json_decode(file_get_contents($url, false, $context));
    }

    and i am calling the
    $create_new_folder = $dropbox->CreateFolder(‘/’.$foldername);

    but it doesn’t create the folder nor it returns any error….
    pls help….

  • sabana sagt:

    Also i tried the below

    function CreateFolder($dropbox_path)
    {
    $url = $this->cleanUrl(self::API_URL.”fileops/create_folder”);
    $content = ‘locale=’.$this->locale.’&root=’.$this->rootPath.’&path=’.$dropbox_path;
    $context = $this->createRequestContext($url, “POST”, $content);
    return json_decode(file_get_contents($url, false, $context));

    }

    but no success.

  • Fabi sagt:

    sabana, your approach seems to be correct, however there was a bug in DropPHP.
    Get the latest version 1.1 https://fabi.me/download/scripts/DropPHP.zip
    It has some fixes and includes new functions GetLink, Delta, Copy, CreateFolder, Delete, Move .

    Please report if that’s working now.

  • Daniel sagt:

    seems to work perfectly!
    thank you man! 😀

  • Denys sagt:

    Hi! If I call “$dropbox->GetAccountInfo()” , I have in my case error

    “Warning: file_get_contents(https://api.dropbox.com/1/account/info): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in /home/dan/WEB/www/uwcIII-dev.my/lib/Social/DropPHP/DropboxClient.php on line 346 NULL “

  • mega sagt:

    UploadFile ist wohl 1. kaputt und 2. die Variable unlogisch benannt.
    Gefühlt muss dort als $dropbox_path der Pfad inkl Dateiname angegeben werden.
    Am Dateiname hängt dann aber ?overwrite=1&locale=en .
    Ist $dropbox_path nur der Pfad ohne Dateiname, heißt die Datei dann einfach nur ‘?overwrite=1&locale=en’
    In der sample.php fehlt der $dropbox_path komplett. Dadurch entsteht eine Datei, auch mit ?overwrite=1&locale=en am Dateiname.

    Ich hoffe mal, das Problem ist leicht lösbar.
    Ansonsten schon mal tolle Sache, nur muss die in PHP eingelesene und bearbeitete Datei auch wieder in die Dropbox zurück kommen.

  • Fabi sagt:

    mega, da hast du Recht. Ich werd mir das mal die Tag anschauen.

  • Kai sagt:

    Ich habe eine Exception beim Autorisieren.
    — ‘DropboxException’ with message ‘Could not get request token! —
    (sample.php) Zeile 49: BuildAuthorizeUrl
    => (DropboxClient.php) Zeile 87: GetRequestToken;
    => (DropboxClient.php) Zeile 51: authCall;
    => (DropboxClient.php) Zeile 335: createRequestContext;
    In der Funktion AuthCall ist $data leer. Ich habe nach parse_str einen print_r($data) gemacht und bekomme nur ein leeres Array angezeigt.

    Muss ich meinen Server noch entsprechend konfigurieren, damit der Dropbox-Zugriff funktioniert?

  • Ryan sagt:

    Downloading and uploading file methods don’t show anything. I am trying to download and upload an image to/from dropbox but I don’t get anything returned from printing out. Am I missing something?

  • Arsalan sagt:

    I’m having problem in uploading file in a particular Linux-based server. The script is running perfectly on some other Windows and Linux servers but in one Linux server, UploadFile() function is doing nothing (not even giving any error). New folder is successfully created in my Dropbox account but no file is getting uploaded. What might be the cause for it?

  • I have the same issue as Denys, above:

    Warning: file_get_contents(https://api.dropbox.com/1/account/info) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in /home/ugandaradio/www/sandbox/DropPHP-master/DropboxClient.php on line 348

    This means that file_get_contents is banned from using dropbox, no?

    Would this mean that cURL would work instead? But… how to rewrite the code for cURL?

  • Daniel sagt:

    Hi
    I’d be amazing if u upload an example of a uploading test. I’m sure that you’ll help many people with that.
    Greetings and thanks!

  • Fabi sagt:

    Hello all,

    just uploaded Version 1.2:
    – Fixed query string parameters issues
    – Added GetLink() to sample.php
    – UploadFile fixed
    – Decreased buffer size

    Upload should work now.

    Daniel, there is an upload test in sample.php

  • JacobJensen sagt:

    Hi, I’m not good at php… could you supply an example of a upload form using your class? This would help a lot of us dummies in the world 😉

  • JacobJensen sagt:

    Sweet! Thank you!!

    In your comments in the code, you mention that I’m supposed to replace the token part with my own… What do you mean? Is yours unsecure or something (got no clue how-to put in my own) 🙂

  • Gabriel C sagt:

    In some websites I’m getting the following errors of Request token not found.
    Other warnings : Undefined index: oauth_token_secret, oauth_token

  • madhu sagt:

    It’s working good. And i need a small help from you.

    –>I am able get photos of the user from his/her Dropbox using your api.
    –> I want to get thumbnails from the user Dropbox. How can i get those thumbnails.

    Can you please send me the solution to my mail.
    My Email id: madhu54108@gmail.com

    Regards,
    Madhu.

  • Dekel Maman sagt:

    Hi
    I can’t get it work, i’m getting error:

    Warning: file_put_contents(tokens/so1z58kvj62w7tz.token) [function.file-put-contents]: failed to open stream: No such file or directory in /home/content/82/8781982/html/magnet/dropbpx/DropPHP/sample.php on line 81
    Authentication required. Click here.

    anyhelp ???

1 2 3 4

Schreibe einen Kommentar zu Michael Antworten abbrechen

Deine E-Mail-Adresse wird nicht veröffentlicht.