[C# Tutorial]How to post comment to YouTube with Form Application

12/30/2012 22:03 Naworia#1
Hello everybody. I'm gonna show you how to post comment to youtube videos only with a button. First we must register an api to do it. So please go to:

Quote:
[Only registered and activated users can see links. Click Here To Register...]
You will see a screen like that :

[Only registered and activated users can see links. Click Here To Register...]

Please click to that button to create a new API for Google.

If you clicked to "Create Project" button, Google will make it.

You will see 4 options these named : Overview, Services, Team and API Access

Please enter to API Access tab:

[Only registered and activated users can see links. Click Here To Register...]

Then click to "Create an OAuth 2.0 cliend ID" button.

Fill up all forms like that(You can put the name what you want) :

[Only registered and activated users can see links. Click Here To Register...]

[Only registered and activated users can see links. Click Here To Register...]

Then click to "Create client ID". After that, go to API Access again:

[Only registered and activated users can see links. Click Here To Register...]

Please open a new notepad and save them :

Quote:
App Name : you commenter
Dev Key : xxxx
Now open Visual Studio and create a new form application.

[Only registered and activated users can see links. Click Here To Register...]

Prepare your design. Because in programming, design is first:

(mm... it is enough xD)
[Only registered and activated users can see links. Click Here To Register...]

Now we will add some references to the project. First download these libraries:

Quote:
[Only registered and activated users can see links. Click Here To Register...]
and add these two libraries to your project(I won't do explain that how to add library to a project as reference).

and add this code start of Form.cs:

HTML Code:
using Google.YouTube;
Now create button_click event and add these:

PHP Code:
YouTubeRequestSettings settings = new YouTubeRequestSettings("app name""dev key"textBox1.TexttextBox2.Text);
YouTubeRequest request = new YouTubeRequest(settings); 
We prepared our request. We will use it to post comment. textBox1.Text is google username of user and textBox2.Text is password of the account.

Now let's prepare our objects. Whare are they? Video and Comment.

PHP Code:
Uri videoUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" textBox3.Text);
Video video request.Retrieve<Video>(videoUrl); 
With these codes, we got our video object. textBox3.Text is our video ID. So it is red marked in following:

Quote:
youtube.com/watch?v=hO2wA0Te0wM
Last one is Comment. It is just like that :

PHP Code:
Comment comment = new Comment();
comment.Content richTextBox1.Text
Now let's start to post comment :

PHP Code:
request.AddComment(videocomment); 
And press F5 to start project :

[Only registered and activated users can see links. Click Here To Register...]

Result :

[Only registered and activated users can see links. Click Here To Register...]

Done !
01/02/2013 05:26 mayur_kulkarni#2
Thanks bro helped a lot . . .
01/02/2013 09:01 #SoNiice#3
With a library it's not very difficulty, but still thanks.
01/02/2013 12:38 Kraizy​#4
[Only registered and activated users can see links. Click Here To Register...]
C&P-Code for every function.