I'm trying to get a video url and title from the Youtube API. Everything is working fine, but I can't show the data - I want to show url and title of the video using json and php only.
My code:
<?php
$get = file_get_contents("http://gdata.youtube.com/feeds/api/videos?vq=cod&orderby=viewCount&max-results=1&start-index=1&alt=json");
$decode = json_decode($get, TRUE); // TRUE for in array format
foreach($decode as $res) {
echo $res['title']['$t'];
}
?>