スキップしてメイン コンテンツに移動

投稿

1月, 2014の投稿を表示しています

Get Youtube Video Detail Information Only Using Javascript

Demo URL Title Duration (Sec) View Count Source code <table border="1"> <tbody> <tr> <td>URL</td> <td><input type="text" id="youtubeVideo_url" style="width:100%"></td> </tr> <tr> <td>Title</td> <td><div id="youtubeVideo_title"></div></td> </tr> <tr> <td>Duration (Sec)</td> <td><div id="youtubeVideo_duration_seconds"></div></td> </tr> <tr> <td>View Count</td> <td><div id="youtubeVideo_view_count"></div></td> </tr> </tbody> </table> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript"> $("#youtubeVideo_url").keyup(function(e){ delay(function(){ var url = $('#yout

Get Youtube Information by PHP cURL

I have written small code snippet for getting information from Youtube by PHP with cURL! The code itself is nothing special, really straightforward manner. The following getVideoInfo function takes youtube video id, access to youtube api and return back the detail video information. function getVideoInfo($id) { try { $req = request('http://gdata.youtube.com/feeds/api/videos/' . $id); $xmlStr = $req->getResponseData(); $xml = simplexml_load_string($xmlStr); $xml->registerXPathNamespace('x', 'http://www.w3.org/2005/Atom'); $xml->registerXPathNamespace('media', 'http://search.yahoo.com/mrss/'); $xml->registerXPathNamespace('yt', 'http://gdata.youtube.com/schemas/2007'); $title = $xml->xpath('/x:entry/media:group/media:title'); $duration_seconds = $xml->xpath('/x:entry/media:group/yt:duration/@seconds'); if (empty($title