Hello guys, in this tutorial I will show you how to rate specific youtube video with Google libraries for C#.
First you should submit an application to google.
So go to this link : [Only registered and activated users can see links. Click Here To Register...]
and create a project.
Note : I don't show you how to create project in google. So you can see some tutorials about it. It is really easy.
So as I said, we will use Google libraries to obtain some functions.
You can get these libraries from : [Only registered and activated users can see links. Click Here To Register...]
Add all libraries to your project and make this references:
Put a button to your form. So when you click to button, it will rate video.
Add these codes to your button_click event:
We created our request object. We will use this to requesting datas to/from server.
What does need the object that named "request"? Video ID and rating count.
So we need specify video ID from video url.
We will get videos from google server so we don't need full youtube url.
If you don't know that what is youtube video ID, it is like it:
We just need to specify rating count. Do it like this:
Ratings can be [1,2,3,4,5].
We did all we need. Except doing request to server.
Click to button that you created before, and done!
Please send message or come skype if you troubled with this tutorial.
First you should submit an application to google.
So go to this link : [Only registered and activated users can see links. Click Here To Register...]
and create a project.
Note : I don't show you how to create project in google. So you can see some tutorials about it. It is really easy.
So as I said, we will use Google libraries to obtain some functions.
You can get these libraries from : [Only registered and activated users can see links. Click Here To Register...]
Add all libraries to your project and make this references:
Code:
using Google.GData.Client; using Google.YouTube;
Add these codes to your button_click event:
Code:
YouTubeRequestSettings settings = new YouTubeRequestSettings("appname", "devkey", "account mail", "account pw");
YouTubeRequest request = new YouTubeRequest(settings);
What does need the object that named "request"? Video ID and rating count.
So we need specify video ID from video url.
Code:
Uri videoUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + "videoID");
If you don't know that what is youtube video ID, it is like it:
Now we should create video object that holding the video informations.Quote:
www.youtube.com/watch?v=XMb63nsvQMo
Red colored text is the ID.
Code:
Video video = request.Retrieve<Video>(videoUrl);
Code:
video.Rating = 5
We did all we need. Except doing request to server.
Code:
request.Insert(video.RatingsUri, video);
Please send message or come skype if you troubled with this tutorial.