Created
August 28, 2014 14:09
-
-
Save rodrigoea/de0ea52ac5227fe88a19 to your computer and use it in GitHub Desktop.
Show Youtube title, description and views count with PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$youtube_id = 'JmRRawnSJEs'; | |
$json_output = file_get_contents("http://gdata.youtube.com/feeds/api/videos/${youtube_id}?v=2&alt=json"); | |
$json = json_decode($json_output, true); | |
//This gives you the video description | |
$video_description = $json['entry']['media$group']['media$description']['$t']; | |
//This gives you the video views count | |
$view_count = $json['entry']['yt$statistics']['viewCount']; | |
//This gives you the video title | |
$video_title = $json['entry']['title']['$t']; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment