Skip to content

shapintv/vimeo

Repository files navigation

Vimeo PHP SDK

Latest version Build status Total downloads

Install

Via Composer

composer require shapintv/vimeo

Usage

Create a VimeoClient

use Shapin\Vimeo\VimeoClient;
use Symfony\Component\HttpClient\HttpClient;

$httpClient = HttpClient::create([
    'base_uri' => 'https://api.vimeo.com/',
    'auth_bearer' => self::VIMEO_TOKEN,
    'headers' => [
        'Content-Type' => 'application/json',
        'Accept' => 'application/vnd.vimeo.*+json;version=3.4',
    ],
]);

$client = new VimeoClient($httpClient);

Deal with videos

// Get a video
$video = $client->videos()->get(362164795);

Integration with symfony

Create a new HttpClient:

framework:
    http_client:
        scoped_clients:
            vimeo.client:
                base_uri: 'https://api.vimeo.com/'
                auth_bearer: '%env(VIMEO_TOKEN)%'
                headers:
                    'Content-Type': 'application/json'
                    'Accept': 'application/vnd.vimeo.*+json;version=3.4'

Then create your service:

services:
    Shapin\Vimeo\VimeoClient: ['@vimeo.client', ~]

When do not use autowiring here in order to avoid the injection of the default Serializer if you have one. This SDK directly build its own Serializer when none is passed which is fine for most use cases.

One day, I may consider creating a bundle in order to bootstrap this SDK...

License

The MIT License (MIT). Please see License File for more information.