Nextcloud PHP API (master)

IClient

Interface IClient

Tags
since
8.1.0

Table of Contents

Constants

DEFAULT_REQUEST_TIMEOUT  = 30
Default request timeout for requests

Methods

delete()  : IResponse
Sends a DELETE request
deleteAsync()  : IPromise
Sends an asynchronous DELETE request
get()  : IResponse
Sends a GET request
getAsync()  : IPromise
Sends an asynchronous GET request
getResponseFromThrowable()  : IResponse
Get the response of a Throwable thrown by the request methods when possible
head()  : IResponse
Sends a HEAD request
headAsync()  : IPromise
Sends an asynchronous HEAD request
options()  : IResponse
Sends an OPTIONS request
optionsAsync()  : IPromise
Sends an asynchronous OPTIONS request
patch()  : IResponse
Sends a PATCH request
post()  : IResponse
Sends a POST request
postAsync()  : IPromise
Sends an asynchronous POST request
put()  : IResponse
Sends a PUT request
putAsync()  : IPromise
Sends an asynchronous PUT request
request()  : IResponse
Sends a HTTP request

Constants

DEFAULT_REQUEST_TIMEOUT

Default request timeout for requests

public mixed DEFAULT_REQUEST_TIMEOUT = 30
Tags
since
31.0.0

Methods

delete()

Sends a DELETE request

public delete(string $uri[, array<string|int, mixed> $options = [] ]) : IResponse
Parameters
$uri : string
$options : array<string|int, mixed> = []

Array such as 'body' => [ 'field' => 'abc', 'other_field' => '123', 'file_name' => fopen('/path/to/file', 'r'), ], 'headers' => [ 'foo' => 'bar', ], 'cookies' => [ 'foo' => 'bar', ], 'allow_redirects' => [ 'max' => 10, // allow at most 10 redirects. 'strict' => true, // use "strict" RFC compliant redirects. 'referer' => true, // add a Referer header 'protocols' => ['https'] // only allow https URLs ], 'sink' => '/path/to/file', // save to a file or a stream 'verify' => true, // bool or string to CA file 'debug' => true,

Tags
throws
Exception

If the request could not get completed

since
8.1.0
Return values
IResponse

deleteAsync()

Sends an asynchronous DELETE request

public deleteAsync(string $uri[, array<string|int, mixed> $options = [] ]) : IPromise
Parameters
$uri : string
$options : array<string|int, mixed> = []

Array such as 'body' => [ 'field' => 'abc', 'other_field' => '123', 'file_name' => fopen('/path/to/file', 'r'), ], 'headers' => [ 'foo' => 'bar', ], 'cookies' => [ 'foo' => 'bar', ], 'allow_redirects' => [ 'max' => 10, // allow at most 10 redirects. 'strict' => true, // use "strict" RFC compliant redirects. 'referer' => true, // add a Referer header 'protocols' => ['https'] // only allow https URLs ], 'sink' => '/path/to/file', // save to a file or a stream 'verify' => true, // bool or string to CA file 'debug' => true,

Tags
since
28.0.0
Return values
IPromise

get()

Sends a GET request

public get(string $uri[, array<string|int, mixed> $options = [] ]) : IResponse
Parameters
$uri : string
$options : array<string|int, mixed> = []

Array such as 'query' => [ 'field' => 'abc', 'other_field' => '123', 'file_name' => fopen('/path/to/file', 'r'), ], 'headers' => [ 'foo' => 'bar', ], 'cookies' => [ 'foo' => 'bar', ], 'allow_redirects' => [ 'max' => 10, // allow at most 10 redirects. 'strict' => true, // use "strict" RFC compliant redirects. 'referer' => true, // add a Referer header 'protocols' => ['https'] // only allow https URLs ], 'sink' => '/path/to/file', // save to a file or a stream 'verify' => true, // bool or string to CA file 'debug' => true,

Tags
throws
Exception

If the request could not get completed

since
8.1.0
Return values
IResponse

getAsync()

Sends an asynchronous GET request

public getAsync(string $uri[, array<string|int, mixed> $options = [] ]) : IPromise
Parameters
$uri : string
$options : array<string|int, mixed> = []

Array such as 'query' => [ 'field' => 'abc', 'other_field' => '123', 'file_name' => fopen('/path/to/file', 'r'), ], 'headers' => [ 'foo' => 'bar', ], 'cookies' => [ 'foo' => 'bar', ], 'allow_redirects' => [ 'max' => 10, // allow at most 10 redirects. 'strict' => true, // use "strict" RFC compliant redirects. 'referer' => true, // add a Referer header 'protocols' => ['https'] // only allow https URLs ], 'sink' => '/path/to/file', // save to a file or a stream 'verify' => true, // bool or string to CA file 'debug' => true,

Tags
since
28.0.0
Return values
IPromise

getResponseFromThrowable()

Get the response of a Throwable thrown by the request methods when possible

public getResponseFromThrowable(Throwable $e) : IResponse
Parameters
$e : Throwable
Tags
throws
Throwable

When $e did not have a response

since
29.0.0
Return values
IResponse

head()

Sends a HEAD request

public head(string $uri[, array<string|int, mixed> $options = [] ]) : IResponse
Parameters
$uri : string
$options : array<string|int, mixed> = []

Array such as 'headers' => [ 'foo' => 'bar', ], 'cookies' => [ 'foo' => 'bar', ], 'allow_redirects' => [ 'max' => 10, // allow at most 10 redirects. 'strict' => true, // use "strict" RFC compliant redirects. 'referer' => true, // add a Referer header 'protocols' => ['https'] // only allow https URLs ], 'sink' => '/path/to/file', // save to a file or a stream 'verify' => true, // bool or string to CA file 'debug' => true,

Tags
throws
Exception

If the request could not get completed

since
8.1.0
Return values
IResponse

headAsync()

Sends an asynchronous HEAD request

public headAsync(string $uri[, array<string|int, mixed> $options = [] ]) : IPromise
Parameters
$uri : string
$options : array<string|int, mixed> = []

Array such as 'headers' => [ 'foo' => 'bar', ], 'cookies' => [ 'foo' => 'bar', ], 'allow_redirects' => [ 'max' => 10, // allow at most 10 redirects. 'strict' => true, // use "strict" RFC compliant redirects. 'referer' => true, // add a Referer header 'protocols' => ['https'] // only allow https URLs ], 'sink' => '/path/to/file', // save to a file or a stream 'verify' => true, // bool or string to CA file 'debug' => true,

Tags
since
28.0.0
Return values
IPromise

options()

Sends an OPTIONS request

public options(string $uri[, array<string|int, mixed> $options = [] ]) : IResponse
Parameters
$uri : string
$options : array<string|int, mixed> = []

Array such as 'body' => [ 'field' => 'abc', 'other_field' => '123', 'file_name' => fopen('/path/to/file', 'r'), ], 'headers' => [ 'foo' => 'bar', ], 'cookies' => [ 'foo' => 'bar', ], 'allow_redirects' => [ 'max' => 10, // allow at most 10 redirects. 'strict' => true, // use "strict" RFC compliant redirects. 'referer' => true, // add a Referer header 'protocols' => ['https'] // only allow https URLs ], 'sink' => '/path/to/file', // save to a file or a stream 'verify' => true, // bool or string to CA file 'debug' => true,

Tags
throws
Exception

If the request could not get completed

since
8.1.0
Return values
IResponse

optionsAsync()

Sends an asynchronous OPTIONS request

public optionsAsync(string $uri[, array<string|int, mixed> $options = [] ]) : IPromise
Parameters
$uri : string
$options : array<string|int, mixed> = []

Array such as 'body' => [ 'field' => 'abc', 'other_field' => '123', 'file_name' => fopen('/path/to/file', 'r'), ], 'headers' => [ 'foo' => 'bar', ], 'cookies' => [ 'foo' => 'bar', ], 'allow_redirects' => [ 'max' => 10, // allow at most 10 redirects. 'strict' => true, // use "strict" RFC compliant redirects. 'referer' => true, // add a Referer header 'protocols' => ['https'] // only allow https URLs ], 'sink' => '/path/to/file', // save to a file or a stream 'verify' => true, // bool or string to CA file 'debug' => true,

Tags
since
28.0.0
Return values
IPromise

patch()

Sends a PATCH request

public patch(string $uri[, array<string|int, mixed> $options = [] ]) : IResponse
Parameters
$uri : string
$options : array<string|int, mixed> = []

Array such as 'body' => [ 'field' => 'abc', 'other_field' => '123', 'file_name' => fopen('/path/to/file', 'r'), ], 'headers' => [ 'foo' => 'bar', ], 'cookies' => [ 'foo' => 'bar', ], 'allow_redirects' => [ 'max' => 10, // allow at most 10 redirects. 'strict' => true, // use "strict" RFC compliant redirects. 'referer' => true, // add a Referer header 'protocols' => ['https'] // only allow https URLs ], 'sink' => '/path/to/file', // save to a file or a stream 'verify' => true, // bool or string to CA file 'debug' => true,

Tags
throws
Exception

If the request could not get completed

since
29.0.0
Return values
IResponse

post()

Sends a POST request

public post(string $uri[, array<string|int, mixed> $options = [] ]) : IResponse
Parameters
$uri : string
$options : array<string|int, mixed> = []

Array such as 'body' => [ 'field' => 'abc', 'other_field' => '123', 'file_name' => fopen('/path/to/file', 'r'), ], 'headers' => [ 'foo' => 'bar', ], 'cookies' => [ 'foo' => 'bar', ], 'allow_redirects' => [ 'max' => 10, // allow at most 10 redirects. 'strict' => true, // use "strict" RFC compliant redirects. 'referer' => true, // add a Referer header 'protocols' => ['https'] // only allow https URLs ], 'sink' => '/path/to/file', // save to a file or a stream 'verify' => true, // bool or string to CA file 'debug' => true,

Tags
throws
Exception

If the request could not get completed

since
8.1.0
Return values
IResponse

postAsync()

Sends an asynchronous POST request

public postAsync(string $uri[, array<string|int, mixed> $options = [] ]) : IPromise
Parameters
$uri : string
$options : array<string|int, mixed> = []

Array such as 'body' => [ 'field' => 'abc', 'other_field' => '123', 'file_name' => fopen('/path/to/file', 'r'), ], 'headers' => [ 'foo' => 'bar', ], 'cookies' => [ 'foo' => 'bar', ], 'allow_redirects' => [ 'max' => 10, // allow at most 10 redirects. 'strict' => true, // use "strict" RFC compliant redirects. 'referer' => true, // add a Referer header 'protocols' => ['https'] // only allow https URLs ], 'sink' => '/path/to/file', // save to a file or a stream 'verify' => true, // bool or string to CA file 'debug' => true,

Tags
since
28.0.0
Return values
IPromise

put()

Sends a PUT request

public put(string $uri[, array<string|int, mixed> $options = [] ]) : IResponse
Parameters
$uri : string
$options : array<string|int, mixed> = []

Array such as 'body' => [ 'field' => 'abc', 'other_field' => '123', 'file_name' => fopen('/path/to/file', 'r'), ], 'headers' => [ 'foo' => 'bar', ], 'cookies' => [ 'foo' => 'bar', ], 'allow_redirects' => [ 'max' => 10, // allow at most 10 redirects. 'strict' => true, // use "strict" RFC compliant redirects. 'referer' => true, // add a Referer header 'protocols' => ['https'] // only allow https URLs ], 'sink' => '/path/to/file', // save to a file or a stream 'verify' => true, // bool or string to CA file 'debug' => true,

Tags
throws
Exception

If the request could not get completed

since
8.1.0
Return values
IResponse

putAsync()

Sends an asynchronous PUT request

public putAsync(string $uri[, array<string|int, mixed> $options = [] ]) : IPromise
Parameters
$uri : string
$options : array<string|int, mixed> = []

Array such as 'body' => [ 'field' => 'abc', 'other_field' => '123', 'file_name' => fopen('/path/to/file', 'r'), ], 'headers' => [ 'foo' => 'bar', ], 'cookies' => [ 'foo' => 'bar', ], 'allow_redirects' => [ 'max' => 10, // allow at most 10 redirects. 'strict' => true, // use "strict" RFC compliant redirects. 'referer' => true, // add a Referer header 'protocols' => ['https'] // only allow https URLs ], 'sink' => '/path/to/file', // save to a file or a stream 'verify' => true, // bool or string to CA file 'debug' => true,

Tags
since
28.0.0
Return values
IPromise

request()

Sends a HTTP request

public request(string $method, string $uri[, array<string|int, mixed> $options = [] ]) : IResponse
Parameters
$method : string

The HTTP method to use

$uri : string
$options : array<string|int, mixed> = []

Array such as 'query' => [ 'field' => 'abc', 'other_field' => '123', 'file_name' => fopen('/path/to/file', 'r'), ], 'headers' => [ 'foo' => 'bar', ], 'cookies' => [ 'foo' => 'bar', ], 'allow_redirects' => [ 'max' => 10, // allow at most 10 redirects. 'strict' => true, // use "strict" RFC compliant redirects. 'referer' => true, // add a Referer header 'protocols' => ['https'] // only allow https URLs ], 'sink' => '/path/to/file', // save to a file or a stream 'verify' => true, // bool or string to CA file 'debug' => true,

Tags
throws
Exception

If the request could not get completed

since
29.0.0
Return values
IResponse

        
On this page

Search results