Last active
June 19, 2020 14:57
-
-
Save zerobugs-oficial/1d838288ceb9823fb8bd5f18181ec0ea to your computer and use it in GitHub Desktop.
Pegando informações sobre um canal no Youtube com PHP - 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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