Skip to content

Instantly share code, notes, and snippets.

@rodrigoea
Created August 28, 2014 14:09
Show Gist options
  • Save rodrigoea/de0ea52ac5227fe88a19 to your computer and use it in GitHub Desktop.
Save rodrigoea/de0ea52ac5227fe88a19 to your computer and use it in GitHub Desktop.
Show Youtube title, description and views count with PHP
<?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