How to get Youtube Views count
Paste the below function in your wordpress functions.php or in any php page and replae the key value with the google api key for youtube data API and the video id with the youtube video id and Voila you get the total number of views for the youtube video
function youtube_view_count_shortcode($params)
{
$videoID = $params['id']; // view id here
$json = file_get_contents("https://www.googleapis.com/youtube/v3/videos?part=statistics&id=" . $videoID . "&key=xxxxxxxxxxxxxxxxxxxxxxxx");
$jsonData = json_decode($json);
$views = $jsonData->items[0]->statistics->viewCount;
return number_format($views);
}
if WordPress, add this below line as well
add_shortcode('youtube_view_count', 'youtube_view_count_shortcode');
Thanks
Hi my name is nima can u plz use this method in my channel plzzzzzz https://youtu.be/CfgCr64oUzg
I want to see if it will work
Hi this is part of coding. do u have a website to list ur youtube?
what website i do now understand
can u increase views