Posted By

GustavModar on 02/02/12


Tagged

youtubeapiphp


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

AllKnightAccess


Get number of views from Youtube api with php


 / Published in: PHP
 

URL: http://stackoverflow.com/questions/3331176/how-to-get-number-of-video-views-with-youtube-api

Get number of Youtube vidfeo views. youtube api

  1. <?php
  2. function get_youtube_views($video_ID) {
  3. $JSON = file_get_contents("https://gdata.youtube.com/feeds/api/videos?q={$video_ID}&alt=json");
  4. $JSON_Data = json_decode($JSON);
  5. $views = $JSON_Data->{'feed'}->{'entry'}[0]->{'yt$statistics'}->{'viewCount'};
  6. echo $views;
  7. }
  8.  
  9. get_youtube_views('5WEK6HgXBsQ');
  10. ?>

Report this snippet  

You need to login to post a comment.