Zend_Gdata_Youtubeを使って投稿者を取得する
Zend_Gdata_Youtubeで動画を検索した際、
投稿者情報(ID)が取得できなかった。
色々と探してみたんだけど見つからなかったので、
無理やり引っ張りだしてみたのでメモ。
objectを強制的にarrayに型キャストして引っ張りだしてます。
<?php require "Zend/Gdata/YouTube.php"; $yt = new Zend_Gdata_YouTube(); $query = $yt->newVideoQuery(); $query->videoQuery = "検索キーワード"; $query->startIndex = 0; $query->maxResults = 50; $query->orderBy = "relevance"; $videoFeed = $yt->getVideoFeed($query); foreach ($videoFeed as $videoEntry) { $author = getAuthor($videoEntry); } function getAuthor($videoEntry) { $video_entry = (array)$videoEntry; $author = (array)$video_entry["\0*\0_author"][0]; $name = (array)$author["\0*\0_name"]; return $name["\0*\0_text"]; } ?>