John Debono

John Debono

  • NA
  • 10
  • 7.5k

Youtube API Posting Comment

May 15 2013 1:15 PM
Hello,

I am try to post a comment on youtube through the use of their api system. So far I have tried the below code but it doesn't seem to work.

This code is global.

YouTubeRequestSettings settings;
        YouTubeRequest request;
        YouTubeService youtube;

This code is found in the form load event of the application. I am using this code to connect with youtube's api.

youtube = new YouTubeService("example app");
            youtube.setUserCredentials("YoutubeUsername", "YoutubePassword");


            try
            {
                string strAuth = youtube.QueryClientLoginToken();
            }
            catch (Exception ex)
            {


            }


            settings = new YouTubeRequestSettings("example app", "DeveloperKey", "YoutubeUsername", "YoutubePassword");
            request = new YouTubeRequest(settings);

To post the comment, I created a button event with the following code.

 Comment c = new Comment();
            c.Content = "Comment";
            Video v = new Video();
            c.Content = "http://www.youtube.com/watch?v=wYjuMxAKe2U";
            request.AddComment(v, c);

For some reason, when I click the button, the comment is not posting on the video.

Thanks.