通过 API 获取 YouTube 用户的完整播放列表列表 [英] Get complete playlist listing for a YouTube User via API

查看:33
本文介绍了通过 API 获取 YouTube 用户的完整播放列表列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,这是我获取 YouTube 用户公开播放列表的代码:

So, here's my code for getting a youtube user's public playlists:

function getyoutubeplaylists($userName) {
$yt = connectyoutube();
$yt->setMajorProtocolVersion(2);
$playlistListFeed = $yt->getPlaylistListFeed($userName);
foreach ($playlistListFeed as $playlistListEntry) {
    $playlist['title'] = $playlistListEntry->title->text;
    $playlist['id'] = $playlistListEntry->getPlaylistID();
    $playlists[] = $playlist;
    $playlistVideoFeed = $yt->getPlaylistVideoFeed($playlistListEntry->getPlaylistVideoFeedUrl());
    foreach ($playlistVideoFeed as $videoEntry) {
        $playlist_assignment['youtube_id'] = substr($videoEntry->getVideoWatchPageUrl(),31,11);
        $playlist_assignment['id'] = $playlist['id'];
        $playlist_assignments[] = $playlist_assignment;
    }
}
$everything['playlists'] = $playlists;
$everything['playlist_assignments'] = $playlist_assignments;
return $everything;
}

问题是,这只能获取第一页或结果.关于如何使用 Zend Gdata 检索下一页结果的任何想法?

Problem is, this only gets the first page or results. Any ideas on how to use the Zend Gdata to retrieve the next page of results?

原始 gdata XML 显示所需的 URL:

The raw gdata XML shows the URLs needed:

<link rel="self" type="application/atom+xml" href="http://gdata.youtube.com/feeds/api/users/pennstate/playlists?start-index=1&amp;max-results=25"/>
<link rel="next" type="application/atom+xml" href="http://gdata.youtube.com/feeds/api/users/pennstate/playlists?start-index=26&amp;max-results=25"/>

但是,getPlaylistListFeed 似乎没有任何参数来指定start-index"或max-results".

However, getPlaylistListFeed doesn't seem to have any parameters to specify "start-index" or "max-results".

推荐答案

听起来您想要关注 关于分页的开发指南示例.

这篇关于通过 API 获取 YouTube 用户的完整播放列表列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆