Tried to do it with simple file_get_contents(); I get a list of videos, but I get only 30, the rest are not getting as they are loaded by ajax. I decided to do it through the API, but it’s even worse, it loads either one video or returns 0 altogether.

 $chanel = "UChpiJbaOTb8x9zhjGApQ3OQ"; $key = "AIzaSyBEiwHcpz6yA4iEF_V3W_t0Ax2-QlI79ck"; $data = file_get_contents("https://www.googleapis.com/youtube/v3/videos?part=snippet&maxResults=50&id=".$chanel."&key=".$key); echo '<pre>'; print_r($data); echo '</pre>'; 

Or maybe there is another way to get the entire list of video feed?

Kye worker bye, then change or disconnect.

    2 answers 2

    To work with Google services, it is probably better to use official libraries, for example google / apiclient.

    YouTube Data API

      Heed the advice - use the Google library. It is better this way. Because most to understand all the "charms" of this terrifying semi-documentary monster - yes, it's easier to hang yourself.

      In vain you have laid out your key like this - the limit has already been exceeded.

      The bottom line is that you needed to use not videos , but search , because The videos really only have one video information (but full), while search gives up to 50 videos (but the description is incomplete and not all the data can be obtained). And yes, maybe somewhere in the official documentation there are examples with videos and there are several results. But not now: the api has changed, but the documentation is neochen (they have updated it somewhere, forgot it somewhere, but somewhere the hybrid has remained).

      In your example, replace the line:

       $data = file_get_contents("https://www.googleapis.com/youtube/v3/videos?part=snippet&maxResults=50&id=".$chanel."&key=".$key); 

      on line:

       $data = file_get_contents("https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=50&id=".$chanel."&key=".$key); 
      • Thank. I have already deleted the key, but I needed to publish what the one who answers would normally test. - Vladimir