Return to Snippet

Revision: 55310
at February 2, 2012 01:14 by GustavModar


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

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

Initial Description
Get number of Youtube vidfeo views.
youtube api

Initial Title
Get number of views from Youtube api with php

Initial Tags

                                

Initial Language
PHP