我使用标准/示例Google API代码列出来自频道的YouTube视频:
$channelsResponse = $youtube->channels->listChannels("contentDetails", array(
"mine" => "true",
));
foreach ($channelsResponse["items"] as $channel) {
$uploadsListId = $channel["contentDetails"]["relatedPlaylists"]["uploads"];
$playlistItemsResponse = $youtube->playlistItems->listPlaylistItems("snippet", array(
"playlistId" => $uploadsListId,
"maxResults" => 50
));
echo "<h3>Videos in list $uploadsListId</h3><ul>";
foreach ($playlistItemsResponse["items"] as $playlistItem) {
echo $playlistItem["snippet"]["title"] . " (" . $playlistItem["snippet"]["resourceId"]["videoId"] . ")<br>";
echo "<img src=" . $playlistItem["snippet"]["thumbnails"]["default"]["url"] . "><br>";
echo "<br><br>";
}
echo "</ul>";
}
然而,它所带回的列表中充满了TONS of On Air Hangout事件,我已经发起了这一事件,但从未点击过“开始广播”按钮,这会导致它们被保存/存档到我的YouTube帐户中。这几乎就像是,在开始之前取消“On Air”环聊广播会创建这些ghost playlistItems ...如何检测它们(并从显示的API调用返回的列表中过滤它们?)