Php 如何列出所有视频ID';来自youtube V3 api中没有播放列表的用户的

Php 如何列出所有视频ID';来自youtube V3 api中没有播放列表的用户的,php,video,youtube-api,youtube-data-api,Php,Video,Youtube Api,Youtube Data Api,我已经上传了大约100个视频到我的频道,我需要获得所有的视频ID,但我搜索的每一个地方都有代码,只列出播放列表中的视频。但我所有的视频都在根目录中 $channelsResponse = $youTubeService->channels->listChannels('id,contentDetails', array( 'mine' => 'true')); $searchResponse = $youTubeService->playlistItems->

我已经上传了大约100个视频到我的频道,我需要获得所有的视频ID,但我搜索的每一个地方都有代码,只列出播放列表中的视频。但我所有的视频都在根目录中

$channelsResponse = $youTubeService->channels->listChannels('id,contentDetails', array(
    'mine' => 'true'));
$searchResponse = $youTubeService->playlistItems->listPlaylistItems('snippet', array(
        'maxResults' => 50,
        'fields' => 'items(snippet(publishedAt,channelId,title,description,thumbnails(default),resourceId)),pageInfo,nextPageToken'));
echo json_encode($searchResponse['items']['contentDetails']['videoId']);

上面的代码从播放列表中获取视频。如何从根目录中获取视频。

没有什么比得上根目录,所有内容都在YouTube的播放列表中。我相信你所要求的是得到你上传的视频。在您的频道中还有一个名为“上传”的播放列表。这就是你的频道上传视频的地方

您可以在ListChannel呼叫中获取该播放列表的播放ID。在回答中,寻找答案

然后在第二次通话(ListPlayItems)中,使用该id设置


工作解决方案/示例:

function getSslPage($url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_REFERER, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}

//params
$order = "date";
$part = "snippet";
$channel_id = "UCzocxfp9lrNal14glrFSrng";
$max_results = 50;
$api_key = "YOUR_API_KEY";

$feedurl = 'https://www.googleapis.com/youtube/v3/search?order='.$order.'&part='.$part.'&channelId='.$channel_id.'&maxResults='.$max_results.'&key='.$api_key;

$feed = getSslPage($feedurl);
$feed_arr = json_decode($feed, true);

//print_r($feed_arr);

$items = $feed_arr['items'];

foreach($items as $item) {
   if( (isset($item['id']['videoId'])) OR (!empty($item['id']['videoId'])) ) {
        echo '<iframe width="420" height="315"
src="http://www.youtube.com/embed/'.$item['id']['videoId'].'?autoplay=0">
</iframe>';
   }
}
函数getSslPage($url){ $ch=curl_init(); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE); curl_setopt($ch,CURLOPT_头,false); curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true); curl_setopt($ch,CURLOPT_URL,$URL); curl_setopt($ch,CURLOPT_REFERER,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE); $result=curl\u exec($ch); 卷曲关闭($ch); 返回$result; } //params $order=“日期”; $part=“snippet”; $channel_id=“UCzocxfp9lrNal14glrFSrng”; $max_结果=50; $api\u key=“您的api\u key”; $feedurl='1https://www.googleapis.com/youtube/v3/search?order=“.$order.&part=.$part.&channelId=.$channel\u id.&maxResults=.$max\u results.&key=.$api\u key; $feed=getSslPage($feedurl); $feed\u arr=json\u decode($feed,true); //打印($feed\u arr); $items=$feed_arr['items']; foreach($items作为$item){ 如果((设置($item['id']['videoId'])或(!empty($item['id']['videoId'])){ 回声' '; } }
我使用的是jquery api,但我认为我的播放列表搞错了,我有一个youtube频道,其中每个播放列表中有两个播放列表p1和p2有10个视频,我想获取p1和p2标题和id,以便仅在第三次请求中获取p1或p2视频