Youtube動画の長さを取得したい。私が試したコードは次のとおりです。
$vidID="voNEBqRZmBc";
//http://www.youtube.com/watch?v=voNEBqRZmBc
$url = "http://gdata.youtube.com/feeds/api/videos/". $vidID;
$doc = new DOMDocument;
$doc->load($url);
$title = $doc->getElementsByTagName("title")->item(0)->nodeValue;
XML ファイルを確認してください。この動画のタイトルがわかりました。から期間を取得したい<yt:duration seconds='29'/>
。
このタグのseconds
属性を取得するには?<yt>