Is there a field for knowing if the youtube channe

2019-02-02 10:24发布

问题:

I am using the Youtube data API and I needed to know if there is any way of finding that the youtube channel is a Verified one.

回答1:

A proper solution, you need to do this in two step :

STEP 1, Using the YouTube Data API v3 and the ressource channel.list with the parameters :

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

This is the output :

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

More at : https://developers.google.com/youtube/v3/docs/channels/list

STEP 2 with the Google Plus API, get the googlePlusUserId from the previous request and use the resource plus.people.get with the parameter:

userId:105350456099841048474

The result will show :

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

The verified field is what you want !

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



回答2:

just ran into this today, and while the channelBranding of the V3 youtube API looks promising, I couldn't get it to return if the account/channel user id was verified or not

so I threw up a pretty lame php script that uses DOM model searching to examine the html directly. to return true if the following element is present.

<a href="//support.google.com/youtube/bin/answer.py?answer=3046484&amp;hl=en" class="qualified-channel-title-badge" target="_blank">

As of today (9/8/2014) a verified user will return 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;
    }
}
?>

Bye for now!



回答3:

If may be possible to check infer the verified status of a youtube channel via the status.longUploadsStatus flag being either allowed or eligible, as currently this feature requires the associated youtube account to be verified.

source : https://developers.google.com/youtube/v3/docs/channels



回答4:

RE: mpgn's solution, note that there's a distinction between whether the G+ account is Verified and whether one or more of the accounts YouTube channels are Verified. It's possible for an account to have more than one channel, and each of those channels are verified independently, and for channels to be unverified even though the associated G+ account is verified.

As @Paul Blakely suggests, the current best way to do this is to check the status.longUploadStatus flag, per https://developers.google.com/youtube/v3/docs/channels



回答5:

On verified channels, the class "has-badge" is present.

Work in 2018:

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

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