YouTube Comments and Commenting with YouTube API V3 (Google.Apis.YouTube.v3)

in #youtube7 years ago



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#


Code Sample

YouTubeService youtube; // Init your service here - Make sure you include the new required scope: YouTubeService.Scope.YoutubeForceSsl
CommentThreadSnippet commentThreadSnippet = new CommentThreadSnippet();

//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)
commentThreadSnippet.TopLevelComment = new Comment() { Snippet = new CommentSnippet() { TextOriginal = comment }};

// Make an insert request and get result snippet
CommentThreadsResource.InsertRequest commentReq = youtube.CommentThreads.Insert(new CommentThread() { Snippet = commentThreadSnippet}, "snippet");
CommentThread commentRes = commentReq.Execute();


Images
YouTube Bulk Uploader for the Lazy

Coin Marketplace

STEEM 0.18
TRX 0.18
JST 0.034
BTC 88157.98
ETH 3083.80
USDT 1.00
SBD 2.74