PhpRiot
Follow phpriot on Twitter
Sponsored Link
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store
Free iPad/iPhone App
Available on the App Store

  • PHP manual
  • Zend Framework manual
  • Smarty manual
  • PHP articles
  • PHP training

Retrieving video comments

The comments for each YouTube video can be retrieved in several ways. To retrieve the comments for the video with the ID 'abc123813abc', use the following code:

Example 449. Retrieving a feed of video comments from a video ID

<?php
$yt 
= new Zend_Gdata_YouTube();
$commentFeed $yt->getVideoCommentFeed('abc123813abc');

foreach (
$commentFeed as $commentEntry) {
    echo 
$commentEntry->title->text "\n";
    echo 
$commentEntry->content->text "\n\n\n";
}

Comments can also be retrieved for a video if you have a copy of the Zend_Gdata_YouTube_VideoEntry object:

Example 450. Retrieving a Feed of Video Comments from a Zend_Gdata_YouTube_VideoEntry

<?php
$yt 
= new Zend_Gdata_YouTube();
$videoEntry $yt->getVideoEntry('abc123813abc');
// we don't know the video ID in this example, but we do have the URL
$commentFeed $yt->getVideoCommentFeed(null,
                                        
$videoEntry->comments->href);

Zend Framework