php - 从网站获取YouTube channel ID

标签 php regex api youtube

我有以下代码,用于从YouTube channel “?q = dsagov”检索 View 和订阅者

$UserID = $_GET['q'];
$data = file_get_contents('http://gdata.youtube.com/feeds/api/users/'. $UserID.'');

$xml = new SimpleXMLElement($data);
$stats_data = (array)$xml->children('yt', true)->statistics->attributes();
$stats_data = $stats_data['@attributes'];

echo 'Views = '.$stats_data['subscriberCount'].'<br />';
echo 'Subscribers = '.$stats_data['totalUploadViews'].'<br />';

我想更进一步,并根据网站地址(在本例中为https://www.gov.uk/government/organisations/driving-standards-agency)找到YouTube channel ID。

因此,可以通过REGEX网站找到 channel ID或其他我不知道使用YouTube API的方法,我可以放置网站的URL并找到官方 channel 吗?

提前致谢。

只是为了澄清
例如,我想在查询“/?q=gov.uk/government/organisations/driving-standards-agency”中输入URL脚本将执行的操作是在URL上找到YouTube channel ID,然后运行API并显示结果

最佳答案

我认为这是不可能的。
您将在哪里搜索网站名称?这可以出现在用户的描述,视频描述中,以及许多用户和视频的更多地方。

关于php - 从网站获取YouTube channel ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22039245/

相关文章:

php - 在 HTML 中搜索和替换单词

正则表达式匹配第一次出现之前和最接近字符串

php - 如何验证这种格式的字符串 : p[1 or more numbers]?

api - 调用 connect 方法时,Web 蓝牙 api 抛出错误 "unsupported device"

python - Twitter 主题标签搜索结果 - 超过 7 天

php - 如何将日文英文字符转换为普通英文字符?

php - 在生产环境中重置 Laravel 迁移

php - 限制 PHP 中 shell_script 的执行时间

python - 如何匹配从一个词到句末?

java - 如何将用户代理字符串与 API 结合使用?