Create a list with the latest videos from a Youtube channel with the V3 API

Asked

Viewed 1,053 times

1

I have a code that takes the last videos from a channel and posts their thumbnails to run in a popup (with jquery, this part works fine).

The code is this:

<?php
    error_reporting(E_ALL);
    $feedURL = 'http://gdata.youtube.com/feeds/api/users/{- USER ID -}/uploads?max-results=50';
    $sxml = simplexml_load_file($feedURL);
    $i = 0;
    foreach ($sxml->entry as $entry):
        $media = $entry->children('media', true);
    $watch = (string)$media->group->player->attributes()->url;
    $thumbnail = (string)$media->group->thumbnail[0]->attributes()->url;
    $right_thumbnail = substr_replace($thumbnail, 'mqdefault', -5, -4);
?>

<li class="thumb-video">
    <a data-link="<?php echo $watch; ?>" id="play-zg-<?= $i; ?>" class="watch-the-video transition-3s">
        <img class="play-button transition-2s" src="<?= $directory_img; ?>/play-yt-icon.png">
        <img src="<?php echo $right_thumbnail;?>" alt="<?php echo $media->group->title; ?>" />
    </a>
</li>

<?php $i++; if($i == 2) { break; }; endforeach; ?>

This code worked great until the google API changed from version 2 to version 3.

The problem is that now I can’t adapt the requirements of the new version of the API to the code, since I don’t understand anything about it =/

Could someone help me?

From now on, thank you =)

Script in header:

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.