【发布时间】:2013-12-27 09:36:09
【问题描述】:
我正在使用 Youtube 数据 API,我需要知道是否有任何方法可以发现 youtube 频道是经过验证的频道。
【问题讨论】:
标签: youtube-api youtube-channels
我正在使用 Youtube 数据 API,我需要知道是否有任何方法可以发现 youtube 频道是经过验证的频道。
【问题讨论】:
标签: youtube-api youtube-channels
在经过验证的频道上,存在“has-badge”类。
2018 年工作:
<?php
$key = 'has-badge';
$channel = file_get_contents('https://www.youtube.com/...');
if( stripos($channel, $key) !== FALSE )
echo "Verified";
else
echo "Not Verified";
?>
【讨论】:
RE:mpgn 的解决方案,请注意,G+ 帐户是否经过验证与一个或多个帐户 YouTube 频道是否经过验证是有区别的。一个帐户可能有多个频道,并且每个频道都经过独立验证,即使关联的 G+ 帐户已验证,频道也可能未经验证。
正如@Paul Blakely 建议的那样,目前最好的方法是检查status.longUploadStatus 标志,每个https://developers.google.com/youtube/v3/docs/channels
【讨论】:
status 部分,否则您将无法访问 longUploadStatus 字段。
如果可以通过 status.longUploadsStatus 标志是否允许或符合条件来检查推断 youtube 频道的已验证状态,因为目前此功能需要验证关联的 youtube 帐户。
【讨论】:
今天刚刚遇到这个问题,虽然 channelBranding of the V3 youtube API 看起来很有希望,但如果帐户/频道用户 ID 已通过验证,我无法返回
所以我抛出了一个非常蹩脚的 php 脚本,它使用 DOM 模型搜索来直接检查 html。 如果存在以下元素,则返回 true。
<a href="//support.google.com/youtube/bin/answer.py?answer=3046484&hl=en" class="qualified-channel-title-badge" target="_blank">
从今天(2014 年 9 月 8 日)起,经过验证的用户将返回 true..
<?php
function isVerified($youtubeUser)
{
$youtubeUser = trim($youtubeUser);
$url = '\''."https://www.youtube.com/user/".$youtubeUser.'\'';
$url = "https://www.youtube.com/user/".$youtubeUser ;
$Verified = false;
echo "<BR>looking at $url ";
$ch = curl_init();
$timeout = 10;
curl_setopt($ch, CURLOPT_URL, "$url");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$html = curl_exec($ch);
curl_close($ch);
$dom = new DOMDocument;
@$dom->loadHTML($html);
foreach ( $dom->getElementsByTagName('a') as $link ) {
$myVar = $link->getAttribute('class');
$search = "qualified-channel-title-badge";
$found=false;
$found = strpos($myVar, $search);
if ( $found !== false) {
$Verified = true; //echo "<BR><font color=green>TRUE</font>";
} else {
$Verified = false; //echo "<BR><font color=red>FALSE</font>";
}
}
if ( $Verified ) {
return true;
} else {
return false;
}
}
?>
再见!
【讨论】: