How can I get number of like/deslike

Showing 1-2 of 2 messages
How can I get number of like/deslike Ahikam Oren 1/12/11 1:23 AM
Hi
I'm working on a project in c# (wpf) and I would like to konw how to get the number of users the likes/deslike a video
Thans Ahikam
Re: How can I get number of like/deslike Jeffrey Posnick 1/13/11 2:12 PM
Hello Ahikam,

 There's no native support for deserializing likes/dislikes into a
property of the Video object in the .NET client library right now.
There might be more elegant ways of getting this information, but
here's some C# code that should work, assuming that the "video"
variable is a properly initialized Video object:

                int likes = -1;
                int dislikes = -1;
                XmlExtension ytRatingElement =
(XmlExtension)video.AtomEntry.FindExtension("rating", "http://
gdata.youtube.com/schemas/2007");
                if (ytRatingElement != null)
                {
                    foreach (XmlAttribute attribute in
ytRatingElement.Node.Attributes)
                    {
                        switch (attribute.Name) {
                            case "numLikes":
                                likes = int.Parse(attribute.Value);
                                break;

                            case "numDislikes":
                                dislikes = int.Parse(attribute.Value);
                                break;
                        }
                    }
                }

Cheers,
-Jeff Posnick, YouTube API Team
~ YouTube is hiring! ~ http://google.com/jobs/workyoutube ~