Get number of views from Youtube api with php


/ Published in: PHP
Save to your folder(s)

Get number of Youtube vidfeo views.
youtube api


Copy this code and paste it in your HTML
  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. ?>

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.