0

Is it possible to get the latest YouTube video thumbnail from my channel? I just want to show 5 latest YouTube video thumbnails on my website, then play the video in a pop up when I click on it.

Show 5 latest YouTube video thumbnail in my website

1 Answers1

0

    $channelid=""; //write the channel id in quotes
    $xml = simplexml_load_file(sprintf('https://www.youtube.com/feeds/videos.xml?channel_id=%s', $channelid));
    $id = $xml->entry[0]->children('yt', true)->videoId[0]; //First Video ID
    $id2 = $xml->entry[0]->children('yt', true)->videoId[1]; //Second Video ID-Duplicate this up to 5
    $thumbimg="http://img.youtube.com/vi/$id/maxresdefault.jpg"; //First Video's thumnail
    $thumbimg2="http://img.youtube.com/vi/$id2/maxresdefault.jpg"; //Second Video's thumnail-Duplicate this up to 5

PLuToNiuM
  • 53
  • 10
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 04 '23 at 17:03