Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400]

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: 411 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(issuer $issuer, $callback)   X-Ref
Create the DropBox API Client.

param: issuer      $issuer     The dropbox issuer
param: string      $callback   The callback URL

get_login_scopes()   X-Ref
Override - Return an empty string to override parent function.

Dropbox does not require scopes to be provided and can function without them.
Additional information MDL-70268

return: string

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.

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

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

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

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

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

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

return: object                  Content decoded from the endpoint
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

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

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

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

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

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.

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

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

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

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.

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

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

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

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

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

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

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

callback()   X-Ref
Process the callback.


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

return: string