Google YouTube API Uploading Videos From Your Web Application To YouTube Using Java

Google YouTube API lets users who want their web applications to be able to upload videos to the YouTube site as well as displaying the user’s uploaded videos. First things first. As the developer, you need to get a developer’s key. You need this to be able to perform write or upload video operations. Go over to this link. Once you have finished submitting your developer information, you need to register a product in order to get a developer key. Once you’ve finished registering, you actually also get a ClientID aside from the developer key. You need both of these two in your code.

To start with, we need to initialize a YouTubeService object which we use for account validation.

Then we call this method

The setFormDetails() method sets two variables token and formUrl which are required values in your HTML form fields. The formUrl would serve as your action URL of the form tag while the token variable will be a hidden field. The action URL must also append a nexturl parameter in order for your browser to redirect it to that URL after upload is finished. Your HTML form field would look like this:

Within the setFormDetails() method, the YouTubeNamespace.CATEGORY_SCHEME lets you specify which Category the video will be set as. This method is purely manual. You can create your own form page with title, description and category that lets the user sets it according to his preference. Just make sure those values are not empty because as they are required by the YouTubeAPI.

Related Posts Plugin for WordPress, Blogger...

Leave a Reply

Your email address will not be published. Required fields are marked *