Hello Reader's If you want o get the total counts of a views on youtube video by api, then you can use the following php code.
<?php
$video_ID = 'your-video-ID'; //set the id from url
$JSON = file_get_contents("https://gdata.youtube.com/feeds/api/videos/{$video_ID}?v=2&alt=json");
$JSON_Data = json_decode($JSON);
$views = $JSON_Data->{'entry'}->{'yt$statistics'}->{'viewCount'};
echo $views;
?>
Now you just have to make this code to as your,
on $vedio_ID set your vedio id. you can get it from url.
Benefit of using this is you don't have to wait until the video finishes.
0 Comment(s)