我有以下代码,用于从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/