Reputation: 31
I am trying to get video mp4 URLs with Vimeo API and its official documentation says to make an authenticated GET request to https://api.vimeo.com/videos/[video_id] Below is a code that I found on github but it doesn't return anything.
$url = "https://api.vimeo.com/videos/$videoid";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36");
$result = curl_exec($ch);
Can someone please suggest me how to make an authenticated GET request to Vimeo API? I have Vimeo keys and access tokens. Thanks.
Upvotes: 1
Views: 592
Reputation: 2470
since you said that you already have your token, you can try this code with that obtained.
Ensure to to also enter your video id. To get video id of your. click on the video to open in a browser. Get your video id of your vimeo account Eg on browser url
https://vimeo.com/12083674
<?php
//$your_video_id='12083674';
$your_video_id='your video id goes here';
$access_token='your access token goes here';
$clink = "https://api.vimeo.com/videos/$your_video_id";
$curl=curl_init();
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl,CURLOPT_URL,$clink);
curl_setopt($curl,CURLOPT_CUSTOMREQUEST,'GET');
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
"Authorization: Bearer $access_token")
);
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,0);
$out = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
var_dump($out);
if($status==200){
echo "video found<br>";
}else{
echo "There is an issue. Try Again..<br>";
}
Upvotes: 4