HttpInterface
in
The transport {@see \YouTube\YouTube} sends every API call through.
Tags
Table of Contents
Methods
- request() : PromiseInterface<string|int, mixed>
- Sends one API call.
- setToken() : void
- The OAuth access token to send, or null to send none.
- stream() : PromiseInterface<string|int, ResponseInterface>
- Opens a server-streamed call: a GET whose response keeps arriving for as long as the server has more to send. Not retried.
Methods
request()
Sends one API call.
public
request(string $endpoint, string $method, string $path[, array<string, mixed> $query = [] ][, array<string, mixed>|JsonSerializable|null $body = null ][, Media|null $media = null ][, string|null $uploadPath = null ][, bool $download = false ]) : PromiseInterface<string|int, mixed>
Parameters
- $endpoint : string
-
The API method, e.g.
liveChatMessages.list, for quota and logs. - $method : string
-
The HTTP verb.
- $path : string
-
Relative to the API root, e.g.
youtube/v3/liveChat/messages. - $query : array<string, mixed> = []
-
Null values are left out; a list repeats its key.
- $body : array<string, mixed>|JsonSerializable|null = null
-
Sent as JSON.
- $media : Media|null = null
-
A file to upload, sent to
$uploadPath. - $uploadPath : string|null = null
-
Where uploads for this method go, e.g.
/upload/youtube/v3/videos. - $download : bool = false
-
Resolve with the response body as it is: a caption file, say.
Return values
PromiseInterface<string|int, mixed> —The decoded JSON, null for an empty response, or the body when downloading.
setToken()
The OAuth access token to send, or null to send none.
public
setToken(?string $token) : void
Parameters
- $token : ?string
stream()
Opens a server-streamed call: a GET whose response keeps arriving for as long as the server has more to send. Not retried.
public
stream(string $endpoint, string $path[, array<string, mixed> $query = [] ]) : PromiseInterface<string|int, ResponseInterface>
Parameters
- $endpoint : string
- $path : string
- $query : array<string, mixed> = []
Return values
PromiseInterface<string|int, ResponseInterface> —Resolves once the headers of a 200 arrive, with a body
that is a React\Stream\ReadableStreamInterface.
Rejects with the mapped exception for any other status.