是否有一个字段用于了解是否通过Youtube API验证了YouTube频道?

时间:2013-12-10 02:17:03

标签: youtube-api youtube-channels

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

5 个答案:

答案 0 :(得分:4)

正确的解决方案,您需要分两步完成:

第1步,使用YouTube Data API v3和带有参数的ressource channel.list

part:contentDetails
id:CHANNEL_ID // or forUsername:USERNAME

这是输出:

  {
   "kind": "youtube#channel",
   "etag": "\"CuSCwMPVmgi8taDtE2LV6HdgkN0/Mu0u2QSDqnFcBvUF5X21CnGSEac\"",
   "id": "UCa10nxShhzNrCE1o2ZOPztg",
   "contentDetails": {
    "relatedPlaylists": {
     "uploads": "UUa10nxShhzNrCE1o2ZOPztg"
    },
    "googlePlusUserId": "105350456099841048474"
   }
  }

更多信息:https://developers.google.com/youtube/v3/docs/channels/list

使用Google Plus API

第2步,从上一个请求中获取googlePlusUserId并使用参数资源plus.people.get

userId:105350456099841048474

结果将显示:

 "isPlusUser": true,
 "plusOneCount": 215098,
 "circledByCount": 12621,
 "verified": true,

验证字段是您想要的!

更多:https://developers.google.com/+/web/api/rest/latest/people/get

答案 1 :(得分:1)

今天遇到了这个问题,虽然channelBranding of the V3 youtube API看起来很有希望,但如果帐户/渠道用户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;
    }
}
?>

再见!

答案 2 :(得分:1)

RE:mpgn的解决方案,请注意,G +帐户是否已经过验证以及一个或多个帐户的YouTube频道是否已经过验证存在差异。帐户可能拥有多个渠道,并且每个渠道都可以独立验证,并且即使关联的G +帐户已经过验证,也可以取消验证渠道。

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

答案 3 :(得分:0)

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

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

答案 4 :(得分:0)

在经过验证的频道上,班级&#34;有徽章&#34;在场。

2018年的工作:

<?php
$key = 'has-badge';
$channel = file_get_contents('https://www.youtube.com/...');

if( stripos($channel, $key) !== FALSE )
    echo "Verified";
else
    echo "Not Verified";
?>