Created
July 19, 2020 10:55
-
-
Save linktoahref/4754121890283d88780641a43e208081 to your computer and use it in GitHub Desktop.
Obtain Access Token from Vimeo API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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