function printVideoFeed($videoFeed, $suggestFlag) { $count = 0; $results = array(); foreach ($videoFeed as $videoEntry) { //var_dump($videoEntry); exit; $videoId = $videoEntry->getVideoId(); //send video id to the if (!is_null(checkForCaptions($videoId))) { $results["entries"][$count]["VideoTitle"] = $videoEntry->getVideoTitle(); $results["entries"][$count]["VideoId"] = $videoEntry->getVideoId(); $results["entries"][$count]["Updated"] = $videoEntry->getUpdated(); $results["entries"][$count]["Description"] = $videoEntry->getVideoDescription(); $results["entries"][$count]["WatchPageUrl"] = $videoEntry->getVideoWatchPageUrl(); $results["entries"][$count]["FlashPlayerUrl"] = $videoEntry->getFlashPlayerUrl(); $results["entries"][$count]["VideoThumbnails"] = $videoEntry->getVideoThumbnails(); $results["entries"][$count]["VideoDuration"] = $videoEntry->getVideoDuration(); $results["entries"][$count]["VideoAuthor"] = $videoEntry->getMediaGroup()->getMediaCredit()->text; //echo "Entry # " . $count . "\n"; //printVideoEntry($videoEntry); //echo "\n"; $count++; } } $results["count"] = $count; $results["suggested_result"] = $suggestFlag; echo '{"results":' . json_encode($results) . '}'; }
<?php require "queryYT.php"; if (isset($_GET['videoId'])) { $videoId = $_GET['videoId']; $captionfilename = urlencode(checkForCaptions($videoId)); $url = "http://www.youtube.com/api/timedtext?lang=en&format=1&v=" . $videoId . "&type=track&kind=&hl=en&name=" . $captionfilename; //echo $url; $result = doCurl($url); if ($result == 404) { echo "error"; exit; } //$result = utf8_encode($result); echo $result; } else { echo "word is not set #fail"; }