string developerKey = "--------------------------";
string username = "example@gmail.com";
string password = "@@@@";//password
YouTubeRequestSettings settings = new YouTubeRequestSettings("Videoapp", null, developerKey, username, password);
YouTubeRequest request = new YouTubeRequest(settings);
Video newvid = new Video();
Uri asdf = new Uri("http://www.youtube.com/watch?v=07rQlP66f2k");
newvid.VideoId = "07rQlP66f2k";
newvid.Rating = 5;
//request.Insert(video.RatingsUri, video); should be like this from youtube api developers guide
request.Insert(asdf, newvid);
what am I doing wrong? Can anyone explain to me and how 开发者_运维问答to do fix it?
You have to retrieve the video first and then you can use the following code to add a rating:
Rating rating = new Rating();
rating.Value = 1;
newvid.YouTubeEntry.Rating = rating;
request.Service.Insert(new Uri(video.YouTubeEntry.RatingsLink.ToString()), video.YouTubeEntry);
Please also note that the numeric gd:rating has been deprecated and replaced by the yt:rating element:
http://code.google.com/apis/youtube/2.0/developers_guide_protocol_ratings.html
精彩评论