Wednesday, December 28, 2011

[YouTube-API] Re: Retrieving an Individual YouTube Video Rating

Hello Michael,

You'll have to get the extension element and attributes manually
since I don't think there's a helper method. The following code should
work, given a valid video entry object and assuming you're using $yt-
>setMajorProtocolVersion(2):

foreach ($videoEntry->getExtensionElements() as $extension) {
if ($extension->rootElement == 'rating') {
$attributes = $extension->getExtensionAttributes();
$likes = $attributes['numLikes']['value'];
$dislikes = $attributes['numDislikes']['value'];
print("$likes likes and $dislikes dislikes\n");
}
}

Cheers,
-Jeff Posnick, YouTube API Team
groups.google.com/group/youtube-api-gdata | apiblog.youtube.com |
@YouTubeDev


On Dec 27, 9:14 pm, "Michael T." <michael.taylor5...@gmail.com> wrote:
> I am trying to find a basic PHP script that would be able to retrieve the
> number of "likes" and "dislikes" for a single video.
>
> The only examples I have seen that retrieve YouTube video ratings use the
> star rating system instead of the current one.
>
> I would really appreciate the help I'm new.
>
> Thank you all! ;-)

--
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.

No comments:

Post a Comment