19

我正在使用 Youtube 数据 API,我需要知道是否有任何方法可以发现 youtube 频道是经过验证的频道。

4

4 回答 4

1

今天刚刚遇到这个问题,虽然V3 youtube API 的 channelBranding看起来很有希望,但如果帐户/频道用户 ID 是否经过验证,我无法让它返回

所以我抛出了一个非常蹩脚的 php 脚本,它使用 DOM 模型搜索来直接检查 html。如果存在以下元素,则返回 true。

<a href="//support.google.com/youtube/bin/answer.py?answer=3046484&amp;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;
    }
}
?>

暂时再见!

于 2014-09-08T18:52:46.223 回答
1

回复:mpgn 的解决方案,请注意,G+ 帐户是否经过验证与一个或多个帐户 YouTube 频道是否经过验证是有区别的。一个帐户可能有多个频道,并且每个频道都经过独立验证,并且即使关联的 G+ 帐户已验证,频道也可能未经验证。

正如@Paul Blakely 建议的那样,目前最好的方法是检查 status.longUploadStatus 标志,每个https://developers.google.com/youtube/v3/docs/channels

于 2016-10-12T17:43:24.337 回答
0

在经过验证的频道上,存在“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";
?>
于 2018-01-05T14:57:59.640 回答
-1

如果可以通过 status.longUploadsStatus 标志是否允许或符合条件来检查推断 youtube 频道的已验证状态,因为目前此功能需要验证关联的 youtube 帐户。

来源:https ://developers.google.com/youtube/v3/docs/channels

于 2015-10-19T15:38:01.900 回答