Skip to content

Instantly share code, notes, and snippets.

@linktoahref
Created July 19, 2020 10:55
Show Gist options
  • Save linktoahref/4754121890283d88780641a43e208081 to your computer and use it in GitHub Desktop.
Save linktoahref/4754121890283d88780641a43e208081 to your computer and use it in GitHub Desktop.
Obtain Access Token from Vimeo API
<?php
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
// Get Access Token from Vimeo
$client = new Client();
try {
$response = $client->request('POST', 'https://api.vimeo.com/oauth/authorize/client', [
'headers' => [
'Authorization' => 'Basic '. base64_encode(config('vimeo.client_id') . ":" . config('vimeo.client_secret')),
'Accept' => 'application/vnd.vimeo.*+json;version=3.4'
],
'json' => [
'grant_type' => 'client_credentials',
'scope' => 'public',
],
]);
$response = json_decode($response->getBody()->getContents());
} catch (RequestException $e) {
dump($e->getResponse()->getBody()->getContents());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment