Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • What is process to get the vedio views from youtube using API in PHP ?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 137
    Comment on it

    Hi Reader's,
    Welcome to FindNerd, today we are going to discuss how to get the video views from youtube using API in PHP ?

    If you want to see the total counts of a views on youtube video by api, then you should use below code:

     <?php 
    //here set the id from url and store in a variable
    $video_ID = "video_id";
    //here call file_get_contents()
    $jsonURL = file_get_contents("https://www.googleapis.com/youtube/v3/videos?id={$video_ID}&key=YOUR_KEY_HERE&part=statistics");
    //here call json_decode()
    $json = json_decode($jsonURL);
    
    $views = $json->{'items'}[0]->{'statistics'}->{'viewCount'};
    echo number_format($views,0,'.',',');
    
     ?>
    

    In above example you have to pass your video_id and you can see total view of your video

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: