Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]

Dropbox V2 API.

Copyright: Andrew Nicols <andrew@nicols.co.uk>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 401 lines (14 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: dropbox  - X-Ref

Dropbox V2 API.

__construct($key, $secret, $callback)   X-Ref
Create the DropBox API Client.

param: string      $key        The API key
param: string      $secret     The API secret
param: string      $callback   The callback URL

auth_url()   X-Ref
Returns the auth url for OAuth 2.0 request.

return: string the auth url

token_url()   X-Ref
Returns the token url for OAuth 2.0 request.

return: string the auth url

get_api_endpoint($endpoint)   X-Ref
Return the constructed API endpoint URL.

param: string      $endpoint   The endpoint to be contacted
return: moodle_url              The constructed API URL

get_content_endpoint($endpoint)   X-Ref
Return the constructed content endpoint URL.

param: string      $endpoint   The endpoint to be contacted
return: moodle_url              The constructed content URL

get_endpoint_for_continue(string $endpoint)   X-Ref
Get the continue endpoint for the provided endpoint.

param: string $endpoint The original endpoint
return: string $endpoint The generated/mapped continue link

fetch_dropbox_data($endpoint, $data = [], string $resultnode = 'entries')   X-Ref
Make an API call against the specified endpoint with supplied data.

param: string      $endpoint   The endpoint to be contacted
param: array       $data       Any data to pass to the endpoint
param: string      $resultnode The name of the node that contains the data
return: object                  Content decoded from the endpoint

has_additional_results($result)   X-Ref
Whether the supplied result is paginated and not the final page.

param: object      $result     The result of an operation
return: boolean

fetch_dropbox_content($endpoint, $data = [])   X-Ref
Fetch content from the specified endpoint with the supplied data.

param: string      $endpoint   The endpoint to be contacted
param: array       $data       Any data to pass to the endpoint
return: string                  The returned data

check_and_handle_api_errors($data)   X-Ref
Check for an attempt to handle API errors.

This function attempts to deal with errors as per
https://www.dropbox.com/developers/documentation/http/documentation#error-handling.

param: mixed      $data       The returned content.

get_listing($path = '')   X-Ref
Get file listing from dropbox.

param: string      $path       The path to query
return: object                  The returned directory listing, or null on failure

search($query = '')   X-Ref
Get file search results from dropbox.

param: string      $query      The search query
return: object                  The returned directory listing, or null on failure

supports_thumbnail($entry)   X-Ref
Whether the entry is expected to have a thumbnail.
See docs at https://www.dropbox.com/developers/documentation/http/documentation#files-get_thumbnail.

param: object      $entry      The file entry received from the DropBox API
return: boolean                 Whether dropbox has a thumbnail available

get_thumbnail($path)   X-Ref
Retrieves the thumbnail for the content, as supplied by dropbox.

param: string      $path       The path to fetch a thumbnail for
return: string                  Thumbnail image content

get_file_share_info($id)   X-Ref
Fetch a valid public share link for the specified file.

param: string      $id         The file path or file id of the file to fetch information for.
return: object                  An object containing the id, path, size, and URL of the entry

normalize_file_share_info($entry)   X-Ref
Normalize the file share info.

param: object $entry   Information retrieved from share endpoints
return: object          Normalized entry information to store as repository information

callback()   X-Ref
Process the callback.


logout()   X-Ref
Revoke the current access token.

return: string