我试图使用PHP获取给定视频的youtube视频评论。我使用Zend框架。以下是我的代码段
$yt = new Zend_Gdata_Youtube();
$feeds = $yt->getVideoCommentFeed($id); // $id is youtube id
while ($feeds) {
foreach ($feeds as $idx => $feed) {
echo $feed->getTitle()."\n"; // work and display the beginning of comment
$author = $feed->getAuthor();
// how to get author name and/or id?
$date = $feed->getPublished();
// how to get the date out if it?
}
$feeds = $yt->getVideoFeed($feeds->getNextLink());
}
如何获取作者的姓名/身份证,发布时间以及每条评论的其他信息?我无法从Zend文档中找到这些信息。
提前致谢,
答案 0 :(得分:0)
$yt = new Zend_Gdata_YouTube();
$commentFeed = $yt->getVideoCommentFeed('abc123813abc');
foreach ($commentFeed as $commentEntry) {
echo $commentEntry->title->text . "\n";
echo $commentEntry->content->text . "\n";
echo $commentEntry->author[0]->name->text. "\n";
echo $commentEntry->author[0]->uri->text. "\n";
echo $commentEntry->published->text. "\n";
}
对于Vlogbrothers Feed:
http://gdata.youtube.com/feeds/api/videos/og8cxXICoVU/comments
示例评论条目
<entry>
<id>http://gdata.youtube.com/feeds/api/videos/og8cxXICoVU/comments/z13tuzmrbk2cszxbx04cjdcoyva4jjliu0c</id>
<published>2014-03-09T20:16:01.000Z</published>
<updated>2014-03-09T20:16:01.000Z</updated>
<category scheme="http://schemas.google.com/g/2005#kind" term="http://gdata.youtube.com/schemas/2007#comment"/>
<title type="text">i also highly ...</title>
<content type="text">i also highly recommend Chop socky chooks- ninja chickens with a piece of
wasabi as their arch nemesis.</content>
<link rel="related" type="application/atom+xml" href="http://gdata.youtube.com/feeds/api/videos/og8cxXICoVU"/>
<link rel="alternate" type="text/html" href="http://www.youtube.com/watch?v=og8cxXICoVU"/>
<link rel="self" type="application/atom+xml" href="http://gdata.youtube.com/feeds/api/videos/og8cxXICoVU/comments/z13tuzmrbk2cszxbx04cjdcoyva4jjliu0c"/>
<author>
<name>Jade Collins</name>
<uri>http://gdata.youtube.com/feeds/api/users/NGsitBKTSKzO-Fioyjy4dw</uri>
</author>
<yt:channelId>UCNGsitBKTSKzO-Fioyjy4dw</yt:channelId>
<yt:googlePlusUserId>118173943933565439685</yt:googlePlusUserId>
<yt:replyCount>0</yt:replyCount>
<yt:videoid>og8cxXICoVU</yt:videoid>
</entry>