I am trying to get the comment count for a video entry but this is giving me a count of 1 when there are no comments. Any ideas?
<?php
$commentFeed = $yt->getVideoCommentFeed($videoID);
if ( count($commentFeed) > 0 )
{
foreach ($commentFeed as $commentEntry)
{
// print commentEntry
}
}
?>
I’m not familiar with the PHP version of the API (I’ve only used the Python one) but I am pretty sure your issue is that when you get
$commentFeed, it is returning the full comment feed XML. This includes a root element named<feed>with a bunch of<entry>elements.So, what you should probably be doing is checking to see if
entrywithin$commentFeedis greater than zero or exists.