Answer the question
In order to leave comments, you need to log in
How to get the latest videos from youtube if requests to its API are quickly scooped up?
There is a script with the following content:
$videoList = json_decode(file_get_contents('https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&channelId='.$channelID.'&maxResults='.$maxResults.'&key='.$API_key.''));
foreach($videoList->items as $item){
//Embed video
if(isset($item->id->videoId)){
echo '<div class="video">
<iframe width="100%" class="youtube-video" src="https://www.youtube.com/embed/'.$item->id->videoId.'" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>';
}
}
Answer the question
In order to leave comments, you need to log in
Do not use the API, pull the page, emulating the browser, and parse it
https://developers.google.com/youtube/v3/determine...
Judging by the fact that you use the search resource, 100 quota units are charged for one request, if the channel is yours, then change the method of sending the request, for example, to videos, then each request will only cost 3
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question