gpt4 book ai didi

php - 使用PHP获取YouTube视频评论详细信息

转载 作者:行者123 更新时间:2023-12-03 05:41:03 24 4
gpt4 key购买 nike

我正在尝试使用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文档中找不到该信息。

提前致谢,

最佳答案

$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>

关于php - 使用PHP获取YouTube视频评论详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22416446/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com