我正在使用 PHP 脚本来查找特定用户 ID 已上传的所有播放列表。问题是脚本没有返回所有播放列表,而只返回其中一些。
我想获取所有播放列表,但并非所有播放列表都被获取。
在这里查看:链接
这是我的代码( GET ARGUMENT 是 /channelname ):
<?php
header('Content-Type: text/html; charset=utf-8');
$feedUrl='https://gdata.youtube.com/feeds/api/users/'.$_GET['id'].'/playlists?v=2&alt=json';
$data = json_decode(file_get_contents($feedUrl),true);
$info = $data["feed"];
$entry = $info["entry"];
$nEntry = count($entry);
/* echo "Playlist Name: ".$info["title"]['$t'].'<br/>';
echo "Number of Videos (".$nVideo."):<br/>";*/
$MainFeed=array();
for($i=0;$i<$nEntry;$i++){
$thumbId=split('/',$entry[$i]['media$group']['media$thumbnail'][0]['url'] );
$thumbId=$thumbId[4];
$playList=array(
'title' => $entry[$i]['title']['$t'],
'playlistId' => $entry[$i]['yt$playlistId']['$t'],
'published'=>$entry[$i]['published']['$t'],
'thumbId'=>$thumbId,
'videosCount'=>$entry[$i]['yt$countHint']['$t'],
'videos'=>getVideos($entry[$i]['yt$playlistId']['$t'])
);
array_push($MainFeed,$playList);
//print_r($entry[$i]);
/*
echo "Name: ".$entry[$i]['title']['$t'].'<br/>';
echo 'http://www.youtube.com/playlist?list='.$entry[$i]['yt$playlistId']['$t'].'&feature=plcp'.'<br/>';
echo '<br>$thumbId : '.$thumbId .'<br>';
echo "playlistId: ".$entry[$i]['yt$playlistId']['$t']."<br />";
echo "published: ".$entry[$i]['published']['$t']."<br />";
*/
// break;
}
echo '{ "feed":'.json_encode($MainFeed).'}';
function getVideos($playListId){
$feedUrl='https://gdata.youtube.com/feeds/api/playlists/'.$playListId.'?v=2&alt=json';
$data = json_decode(file_get_contents($feedUrl),true);
$info = $data["feed"];
$entry = $info["entry"];
$nEntry = count($entry);
$PLayListVideos=array();
for($i=0;$i<$nEntry;$i++){
$video = array(
'title' => $entry[$i]['title']['$t'],
'description' => $entry[$i]['media$group']['media$description']['$t'],
'published' =>$entry[$i]['published']['$t'],
'duration'=>$entry[$i]['media$group']['yt$duration']['seconds'],
'videoid'=>$entry[$i]['media$group']['yt$videoid']['$t'],
'favoriteCount'=>$entry[$i]['yt$statistics']['favoriteCount'],
'viewCount'=>$entry[$i]['yt$statistics']['viewCount'],
'numDislikes'=>$entry[$i]['yt$rating']['numDislikes'],
'numLikes'=>$entry[$i]['yt$rating']['numLikes'],
'rating'=>$entry[$i]['gd$rating']['average'],
'max'=>$entry[$i]['gd$rating']['max'],
'min'=>$entry[$i]['gd$rating']['min'] ,
'numRaters'=>$entry[$i]['gd$rating']['numRaters'] ,
'rtsp1'=>$entry[$i]['media$group']['media$content']['1']['url'],
'rtsp2'=>$entry[$i]['media$group']['media$content']['2']['url'],
);
array_push($PLayListVideos,$video);
/*
echo "Name: ".$entry[$i]['title']['$t'].'<br/>';
echo "published: ".$entry[$i]['published']['$t']."<br />";
echo "duration : ".$entry[$i]['media$group']['yt$duration']['seconds'].'<br/>';
echo "videoid : ".$entry[$i]['media$group']['yt$videoid']['$t'].'<br/>';
echo "Image 90 : ".$entry[$i]['media$group']['media$thumbnail'][0]['url'].'<br/>';
echo "Image 180 : ".$entry[$i]['media$group']['media$thumbnail'][1]['url'].'<br/>';
echo "Image 360 : ".$entry[$i]['media$group']['media$thumbnail'][2]['url'].'<br/>';
echo "favoriteCount : ".$entry[$i]['yt$statistics']['favoriteCount'] .'<br/>';
echo "viewCount : ".$entry[$i]['yt$statistics']['viewCount'] .'<br/>';
echo "numDislikes : ".$entry[$i]['yt$rating']['numDislikes'] .'<br/>';
echo "numLikes : ".$entry[$i]['yt$rating']['numLikes'] .'<br/>';
echo "rating : ".$entry[$i]['gd$rating']['average'] .'<br/>';
echo "max : ".$entry[$i]['gd$rating']['max'] .'<br/>';
echo "min : ".$entry[$i]['gd$rating']['min'] .'<br/>';
echo "numRaters : ".$entry[$i]['gd$rating']['numRaters'] .'<br/>';
echo "rtsp1 : ".$entry[$i]['media$group']['media$content']['1']['url'] .'<br/>';
echo "rtsp2 : ".$entry[$i]['media$group']['media$content']['2']['url'] .'<br/>';
*/
//print_r($entry[$i]);
}
return $PLayListVideos;
}
?>
如何进行更改以获取频道拥有的所有播放列表?