Reputation: 907
I have a script that grabs the duration of a Youtube video.
It was working fine but for some reason it now gets the following error:
Warning: file_get_contents(https://www.googleapis.com/youtube/v3/videos?part=contentDetails&id=Prt-G4cPIn4&key=[API_KEY]): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden
Here's the code:
$dur = file_get_contents("https://www.googleapis.com/youtube/v3/videos?part=contentDetails&id=$video_id&key=$apikey");
$duration = json_decode($dur, true);
foreach ($duration['items'] as $vidTime) {
$vTime = new DateInterval($vidTime['contentDetails']['duration']);
}
$vid_time = $vTime->format('%H:%I:%S');
I have no idea why this would stop working all of a sudden.
Upvotes: 0
Views: 89
Reputation: 51
The var $apikey is wrong "[API_KEY]", solve this first and go appear other error, comming by the headers and CORS
Upvotes: 0