开发者

youtube api Rating not working?

开发者 https://www.devze.com 2023-03-11 09:10 出处:网络
string developerKey = \"--------------------------\"; string username = \"example@gmail.com\"; string password = \"@@@@\";//password
  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

0

精彩评论

暂无评论...
验证码 换一张
取 消