Skip to content

Instantly share code, notes, and snippets.

@zerobugs-oficial
Last active June 19, 2020 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zerobugs-oficial/1d838288ceb9823fb8bd5f18181ec0ea to your computer and use it in GitHub Desktop.
Save zerobugs-oficial/1d838288ceb9823fb8bd5f18181ec0ea to your computer and use it in GitHub Desktop.
Pegando informações sobre um canal no Youtube com PHP - 1
function get_youtube_channel_stat($stat = 'viewCount'){
// o parâmetro $stat pode ser: viewCount, commentCount, subscriberCount ou videoCount
$key = "AIzaSyCTsbFFDGQdCD1xu3S99H1AzXdRpaALnr0"; // Sua API Key
$channel_id = "UC6BN1oSRAxcABupjn_bnT7g"; // a ID do seu canal
$content = file_get_contents("https://www.googleapis.com/youtube/v3/channels?key={$key}&part=statistics&id={$channel_id}");
$json = json_decode($content, 1);
return $json['items'][0]['statistics'][$stat];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment