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

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 183
    Comment on it

    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)

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: