Google deprecated V2 of the YouTube API over a year ago, but as of last month, the URLs have been taken offline; forcing users to upgrade to V3 of the API. One of the last features requiring implementating on the V3 platform was the ability to comment on channels and videos. The following example shows how to leave a top level comment on a channel or video using V3 of the API with C#
Example
Code Snippet
- YouTubeService youtube; // Init your service here - Make sure you include the new required scope: YouTubeService.Scope.YoutubeForceSsl
- //commentThreadSnippet.ChannelId; Comment on a channel - leave video id blank if so
- commentThreadSnippet.VideoId = v.ID; // Comment on a Video by VideoID
- // A top level comment is a new comment (Not a reply to an existing comment)
- // Make an insert request and get result snippet
- CommentThreadsResource.InsertRequest commentReq = youtube.CommentThreads.Insert(new CommentThread() { Snippet = commentThreadSnippet}, "snippet");
- CommentThread commentRes = commentReq.Execute();
End of Code Snippet