Vimeo
in package
Table of Contents
- ACCESS_TOKEN_ENDPOINT = '/oauth/access_token'
- AUTH_ENDPOINT = 'https://api.vimeo.com/oauth/authorize'
- CERTIFICATE_PATH = '/certificates/vimeo-api.pem'
- CLIENT_CREDENTIALS_TOKEN_ENDPOINT = '/oauth/authorize/client'
- ROOT_ENDPOINT = 'https://api.vimeo.com'
- USER_AGENT = 'vimeo.php 3.0.5; (http://developer.vimeo.com/api/docs)'
- VERSION_STRING = 'application/vnd.vimeo.*+json; version=3.4'
- VERSIONS_ENDPOINT = '/versions'
- $_curl_opts : array<string|int, mixed>
- $CURL_DEFAULTS : array<string|int, mixed>
- $_access_token : null|string
- $_client_id : null|string
- $_client_secret : null|string
- __construct() : mixed
- Creates the Vimeo library, and tracks the client and token information.
- accessToken() : array<string|int, mixed>
- Request an access token. This is the final step of the OAuth 2 workflow, and should be called from your redirect url.
- buildAuthorizationEndpoint() : string
- Build the url that your user.
- clientCredentials() : array<string|int, mixed>
- Get client credentials for requests.
- getCURLOptions() : array<string|int, mixed>
- Gets custom cURL options.
- getToken() : string
- Request the access token associated with this library.
- parse_headers() : array<string|int, mixed>
- Convert the raw headers string into an associated array
- replace() : string
- Replace the source of a single Vimeo video.
- request() : array<string|int, mixed>
- Make an API request to Vimeo.
- setCURLOptions() : void
- Sets custom cURL options.
- setProxy() : void
- Set a proxy to pass all API requests through.
- setToken() : void
- Assign a new access token to this library.
- upload() : string
- Upload a file.
- uploadImage() : string
- Uploads an image to an individual picture response.
- uploadTexttrack() : string
- Uploads a text track.
- _authHeader() : string
- Get authorization header for retrieving tokens/credentials.
- _request() : array<string|int, mixed>
- Internal function to handle requests, both authenticated and by the upload function.
- getTusUploadChunkSize() : int
- Enforces the notion that a user may supply any `proposed_chunk_size`, as long as it results in 1024 or less proposed chunks. In the event it does not, then the chunk size becomes the file size divided by 1024.
- perform_upload_tus() : string
- Take an upload attempt and perform the actual upload via tus.
Constants
ACCESS_TOKEN_ENDPOINT
public
mixed
ACCESS_TOKEN_ENDPOINT
= '/oauth/access_token'
AUTH_ENDPOINT
public
mixed
AUTH_ENDPOINT
= 'https://api.vimeo.com/oauth/authorize'
CERTIFICATE_PATH
public
mixed
CERTIFICATE_PATH
= '/certificates/vimeo-api.pem'
CLIENT_CREDENTIALS_TOKEN_ENDPOINT
public
mixed
CLIENT_CREDENTIALS_TOKEN_ENDPOINT
= '/oauth/authorize/client'
ROOT_ENDPOINT
public
mixed
ROOT_ENDPOINT
= 'https://api.vimeo.com'
USER_AGENT
public
mixed
USER_AGENT
= 'vimeo.php 3.0.5; (http://developer.vimeo.com/api/docs)'
VERSION_STRING
public
mixed
VERSION_STRING
= 'application/vnd.vimeo.*+json; version=3.4'
VERSIONS_ENDPOINT
public
mixed
VERSIONS_ENDPOINT
= '/versions'
Properties
$_curl_opts
protected
array<string|int, mixed>
$_curl_opts
= array()
$CURL_DEFAULTS
protected
array<string|int, mixed>
$CURL_DEFAULTS
= array()
$_access_token
private
null|string
$_access_token
= null
$_client_id
private
null|string
$_client_id
= null
$_client_secret
private
null|string
$_client_secret
= null
Methods
__construct()
Creates the Vimeo library, and tracks the client and token information.
public
__construct(string $client_id, string $client_secret[, string|null $access_token = null ]) : mixed
Parameters
- $client_id : string
-
Your applications client id. Can be found on developer.vimeo.com/apps
- $client_secret : string
-
Your applications client secret. Can be found on developer.vimeo.com/apps
- $access_token : string|null = null
-
Your access token. Can be found on developer.vimeo.com/apps or generated using OAuth 2.
Return values
mixed —accessToken()
Request an access token. This is the final step of the OAuth 2 workflow, and should be called from your redirect url.
public
accessToken(string $code, string $redirect_uri) : array<string|int, mixed>
Parameters
- $code : string
-
The authorization code that was provided to your redirect url
- $redirect_uri : string
-
The redirect_uri that is configured on your app page, and was used in buildAuthorizationEndpoint
Return values
array<string|int, mixed> —This array contains three keys, 'status' is the status code, 'body' is an object representation of the json response body, and headers are an associated array of response headers
buildAuthorizationEndpoint()
Build the url that your user.
public
buildAuthorizationEndpoint(string $redirect_uri[, string|array<string|int, mixed>|null $scope = 'public' ][, string|null $state = null ]) : string
Parameters
- $redirect_uri : string
-
The redirect url that you have configured on your app page
- $scope : string|array<string|int, mixed>|null = 'public'
-
An array of scopes that your final access token needs to access
- $state : string|null = null
-
A random variable that will be returned on your redirect url. You should validate that this matches
Return values
string —clientCredentials()
Get client credentials for requests.
public
clientCredentials([mixed $scope = 'public' ]) : array<string|int, mixed>
Parameters
- $scope : mixed = 'public'
-
Scopes to request for this token from the server.
Return values
array<string|int, mixed> —Response from the server with the tokens, we also set it into this object.
getCURLOptions()
Gets custom cURL options.
public
getCURLOptions() : array<string|int, mixed>
Return values
array<string|int, mixed> —getToken()
Request the access token associated with this library.
public
getToken() : string
Return values
string —parse_headers()
Convert the raw headers string into an associated array
public
static parse_headers(string $headers) : array<string|int, mixed>
Parameters
- $headers : string
Return values
array<string|int, mixed> —replace()
Replace the source of a single Vimeo video.
public
replace(string $video_uri, string $file_path[, array<string|int, mixed> $params = array() ]) : string
Parameters
- $video_uri : string
-
Video uri of the video file to replace.
- $file_path : string
-
Path to the video file to upload.
- $params : array<string|int, mixed> = array()
Tags
Return values
string —Video URI
request()
Make an API request to Vimeo.
public
request(string $url[, array<string|int, mixed> $params = array() ][, string $method = 'GET' ][, bool $json_body = true ][, array<string|int, mixed> $headers = array() ]) : array<string|int, mixed>
Parameters
- $url : string
-
A Vimeo API Endpoint. Should not include the host
- $params : array<string|int, mixed> = array()
-
An array of parameters to send to the endpoint. If the HTTP method is GET, they will be added to the url, otherwise they will be written to the body
- $method : string = 'GET'
-
The HTTP Method of the request
- $json_body : bool = true
- $headers : array<string|int, mixed> = array()
-
An array of HTTP headers to pass along with the request.
Tags
Return values
array<string|int, mixed> —This array contains three keys, 'status' is the status code, 'body' is an object representation of the json response body, and headers are an associated array of response headers
setCURLOptions()
Sets custom cURL options.
public
setCURLOptions([array<string|int, mixed> $curl_opts = array() ]) : void
Parameters
- $curl_opts : array<string|int, mixed> = array()
-
An associative array of cURL options.
Return values
void —setProxy()
Set a proxy to pass all API requests through.
public
setProxy(string $proxy_address[, string|null $proxy_port = null ][, string|null $proxy_userpwd = null ]) : void
Parameters
- $proxy_address : string
-
Mandatory address of proxy.
- $proxy_port : string|null = null
-
Optional number of port.
- $proxy_userpwd : string|null = null
-
Optional
user:password
authentication.
Return values
void —setToken()
Assign a new access token to this library.
public
setToken(string $access_token) : void
Parameters
- $access_token : string
-
the new access token
Return values
void —upload()
Upload a file.
public
upload(string $file_path[, array<string|int, mixed> $params = array() ]) : string
This should be used to upload a local file. If you want a form for your site to upload direct to Vimeo, you
should look at the POST /me/videos
endpoint.
Parameters
- $file_path : string
-
Path to the video file to upload.
- $params : array<string|int, mixed> = array()
-
Parameters to send when creating a new video (name, privacy restrictions, etc.).
Tags
Return values
string —Video URI
uploadImage()
Uploads an image to an individual picture response.
public
uploadImage(string $pictures_uri, string $file_path[, bool $activate = false ]) : string
Parameters
- $pictures_uri : string
-
The pictures endpoint for a resource that allows picture uploads (eg videos and users)
- $file_path : string
-
The path to your image file
- $activate : bool = false
-
Activate image after upload
Tags
Return values
string —The URI of the uploaded image.
uploadTexttrack()
Uploads a text track.
public
uploadTexttrack(string $texttracks_uri, string $file_path, string $track_type, string $language) : string
Parameters
- $texttracks_uri : string
-
The text tracks uri that we are adding our text track to
- $file_path : string
-
The path to your text track file
- $track_type : string
-
The type of your text track
- $language : string
-
The language of your text track
Tags
Return values
string —The URI of the uploaded text track.
_authHeader()
Get authorization header for retrieving tokens/credentials.
private
_authHeader() : string
Return values
string —_request()
Internal function to handle requests, both authenticated and by the upload function.
private
_request(string $url[, array<string|int, mixed> $curl_opts = array() ]) : array<string|int, mixed>
Parameters
- $url : string
- $curl_opts : array<string|int, mixed> = array()
Tags
Return values
array<string|int, mixed> —getTusUploadChunkSize()
Enforces the notion that a user may supply any `proposed_chunk_size`, as long as it results in 1024 or less proposed chunks. In the event it does not, then the chunk size becomes the file size divided by 1024.
private
getTusUploadChunkSize(int $proposed_chunk_size, int $file_size) : int
Parameters
- $proposed_chunk_size : int
- $file_size : int
Return values
int —perform_upload_tus()
Take an upload attempt and perform the actual upload via tus.
private
perform_upload_tus(string $file_path, int|float $file_size, array<string|int, mixed> $attempt) : string
Parameters
- $file_path : string
-
Path to the video file to upload.
- $file_size : int|float
-
Size of the video file.
- $attempt : array<string|int, mixed>
-
Upload attempt data.