Constants

API_URL

API_URL = 'https://api.onedrive.com/v1.0'

AUTH_URL

AUTH_URL = 'https://login.live.com/oauth20_authorize.srf'

TOKEN_URL

TOKEN_URL = 'https://login.live.com/oauth20_token.srf'

Properties

$_clientId

$_clientId

$_state

$_state

$_httpStatus

$_httpStatus

$_contentType

$_contentType

Methods

__construct()

__construct(array  $options = array()) : mixed

Constructor.

Parameters

array $options

Returns

mixed —

getState()

getState() : (object)

Gets the current state of this Client instance. Typically saved in the session and passed back to the Client constructor for further requests.

Returns

(object) —

The state of this Client instance.

setState()

setState(mixed  $arr) : mixed

Parameters

mixed $arr

Returns

mixed —

getLogInUrl()

getLogInUrl((array)  $scopes, (string)  $redirectUri, array  $options = array()) : (string)

Gets the URL of the log in form. After login, the browser is redirected to the redirect URL, and a code is passed as a GET parameter to this URL.

The browser is also redirected to this URL if the user is already logged in.

Parameters

(array) $scopes
  • The OneDrive scopes requested by the application. Supported values: 'wl.signin', 'wl.basic', 'wl.contacts_skydrive', 'wl.skydrive_update'.
(string) $redirectUri
  • The URI to which to redirect to upon successful log in.
array $options

Returns

(string) —

The login URL.

getTokenExpire()

getTokenExpire() : (int)

Gets the access token expiration delay.

Returns

(int) —

The token expiration delay, in seconds.

getAccessTokenStatus()

getAccessTokenStatus() : (int)

Gets the status of the current access token.

Returns

(int) —

The status of the current access token: 0 => no access token -1 => access token will expire soon (1 minute or less) -2 => access token is expired 1 => access token is valid

obtainAccessToken()

obtainAccessToken((string)  $clientSecret, (string)  $code) : mixed

Obtains a new access token from OAuth. This token is valid for one hour.

Parameters

(string) $clientSecret
  • The OneDrive client secret.
(string) $code
  • The code returned by OneDrive after successful log in.

Returns

mixed —

refreshAccessToken()

refreshAccessToken(mixed  $clientSecret, mixed  $refresh_token) : mixed

Parameters

mixed $clientSecret
mixed $refresh_token

Returns

mixed —

fetchAccountInfo()

fetchAccountInfo() : (object)

Fetches the account info of the current OneDrive account.

Returns

(object) —

An object with the following properties: (string) id - OneDrive account ID. (string) first_name - account owner's first name. (string) last_name - account owner's last name. (string) name - account owner's full name. (string) gender - account owner's gender. (string) locale - account owner's locale.

fetchChildren()

fetchChildren(mixed  $path, mixed  $parameter) : mixed

Parameters

mixed $path
mixed $parameter

Returns

mixed —

fetchObject()

fetchObject(mixed  $path = '') : (object)

Fetches an object from the current OneDrive account.

Parameters

mixed $path

Returns

(object) —

The object fetched, as an Object instance referencing to the OneDrive object fetched.

updateObject()

updateObject(mixed  $path, (array|object)  $properties = array()) : mixed

Updates the properties of an object in the current OneDrive account.

Parameters

mixed $path
(array|object) $properties
  • The properties to update. Default: array().

Throws

(\Exception)

Thrown on I/O errors.

Returns

mixed —

thumbnails()

thumbnails(mixed  $path, mixed  $width, mixed  $height, mixed  $type = '') : mixed

Parameters

mixed $path
mixed $width
mixed $height
mixed $type

Returns

mixed —

createFolder()

createFolder(mixed  $path, (string)  $name, mixed  $ondup = 'fail') : (\Folder)

Creates a folder in the current OneDrive account.

Parameters

mixed $path
(string) $name
  • The name of the OneDrive folder to be created.
mixed $ondup

Returns

(\Folder) —

The folder created, as a Folder instance referencing to the OneDrive folder created.

createFile()

createFile(mixed  $path = null, (string)  $name, (string)  $content = '') : (\File)

Creates a file in the current OneDrive account.

Parameters

mixed $path
(string) $name
  • The name of the OneDrive file to be created.
(string) $content
  • The content of the OneDrive file to be created.

Throws

(\Exception)

Thrown on I/O errors.

Returns

(\File) —

The file created, as File instance referencing to the OneDrive file created.

uploadFile()

uploadFile(mixed  $path = null, mixed  $name, mixed  $file) : mixed

Parameters

mixed $path
mixed $name
mixed $file

Returns

mixed —

fetchRoot()

fetchRoot() : (\Folder)

Fetches the root folder from the current OneDrive account.

Returns

(\Folder) —

The root folder, as a Folder instance referencing to the OneDrive root folder.

createSession()

createSession(mixed  $path, mixed  $name, mixed  $ondup = 'rename') : mixed

Parameters

mixed $path
mixed $name
mixed $ondup

Returns

mixed —

cancelSession()

cancelSession(mixed  $uploadUrl) : mixed

Parameters

mixed $uploadUrl

Returns

mixed —

uploadFragment()

uploadFragment(mixed  $uploadUrl, mixed  $file, mixed  $contentRange) : mixed

Parameters

mixed $uploadUrl
mixed $file
mixed $contentRange

Returns

mixed —

createLink()

createLink(mixed  $path, mixed  $type = 'view') : mixed

Parameters

mixed $path
mixed $type

Returns

mixed —

moveObject()

moveObject(mixed  $path, mixed  $tpath = null) : mixed

Moves an object into another folder.

Parameters

mixed $path
mixed $tpath

Returns

mixed —

copyObject()

copyObject(mixed  $path, mixed  $tpath = null) : mixed

Copies a file into another folder. OneDrive does not support copying folders.

Parameters

mixed $path
mixed $tpath

Returns

mixed —

deleteObject()

deleteObject(mixed  $path) : mixed

Deletes an object in the current OneDrive account.

Parameters

mixed $path

Returns

mixed —

fetchShared()

fetchShared() : (object)

Fetches the objects shared with the current OneDrive account.

Returns

(object) —

An object with the following properties: (array) data - The list of the shared objects.

apiGet()

apiGet((string)  $path, (array)  $options = array(), mixed  $data = array()) : mixed

Performs a call to the OneDrive API using the GET method.

Parameters

(string) $path
  • The path of the API call (eg. me/skydrive).
(array) $options
  • Further curl options to set.
mixed $data

Returns

mixed —

apiPost()

apiPost((string)  $path, (array|object)  $data) : mixed

Performs a call to the OneDrive API using the POST method.

Parameters

(string) $path
  • The path of the API call (eg. me/skydrive).
(array|object) $data
  • The data to pass in the body of the request.

Returns

mixed —

apiPut()

apiPut((string)  $path, (resource)  $stream, mixed  $extraheader = null) : mixed

Performs a call to the OneDrive API using the PUT method.

Parameters

(string) $path
  • The path of the API call (eg. me/skydrive).
(resource) $stream
  • The data stream to upload.
mixed $extraheader

Returns

mixed —

apiPatch()

apiPatch((string)  $path, mixed  $data) : mixed

Performs a call to the OneDrive API using the PUT method.

Parameters

(string) $path
  • The path of the API call (eg. me/skydrive).
mixed $data

Returns

mixed —

apiDelete()

apiDelete((string)  $path) : mixed

Performs a call to the OneDrive API using the DELETE method.

Parameters

(string) $path
  • The path of the API call (eg. me/skydrive).

Returns

mixed —

apiMove()

apiMove((string)  $path, (array|object)  $data) : mixed

Performs a call to the OneDrive API using the MOVE method.

Parameters

(string) $path
  • The path of the API call (eg. me/skydrive).
(array|object) $data
  • The data to pass in the body of the request.

Returns

mixed —

apiCopy()

apiCopy((string)  $path, (array|object)  $data) : mixed

Performs a call to the OneDrive API using the COPY method.

Parameters

(string) $path
  • The path of the API call (eg. me/skydrive).
(array|object) $data
  • The data to pass in the body of the request.

Returns

mixed —

_createCurl()

_createCurl(mixed  $path, mixed  $options = array()) : mixed

Parameters

mixed $path
mixed $options

Returns

mixed —

_processResult()

_processResult((resource)  $curl) : (object|string)

Processes a result returned by the OneDrive API call using a cURL object.

Parameters

(resource) $curl
  • The cURL object used to perform the call.

Returns

(object|string) —

The content returned, as an object instance if served a JSON, or as a string if served as anything else.