gpt4 book ai didi

php - 如何获取YouTube channel 中最新上传视频的ID

转载 作者:行者123 更新时间:2023-12-04 14:12:56 26 4
gpt4 key购买 nike

在优酷上我如何获取我订阅的 channel 的最新上传视频的 ID(在 url 中出现的视频,如 v=....),用于嵌入
我在我的服务器端使用 php

最佳答案

截至 2015 年 4 月 20 日,上述答案似乎不再有效。下面是一个使用 YouTube channel ID 的示例(可以在 channel 页面的源代码中找到。)

<?php

$id = NULL;
$channel_id = 'someChannelID';

$xml = simplexml_load_file(sprintf('https://www.youtube.com/feeds/videos.xml?channel_id=%s', $channel_id));

if (!empty($xml->entry[0]->children('yt', true)->videoId[0])){
$id = $xml->entry[0]->children('yt', true)->videoId[0];
}

echo $id; // Outputs the video ID.

关于php - 如何获取YouTube channel 中最新上传视频的ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6617567/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com