Post navigation

YouTube API – OAuth and Upload Example

Today I would like to talk about video. Maybe you’ve got own video website, maybe you’re thinking about it, but anyway I think that our new information will be useful for you. As you know, video usually means that you need to have a lot of space at your hosting. And it is true in case if you store video files at your own server. But, in order to avoid all these difficulties (video storing and conversion), you can try to work with 3-rd party video hostings. As example youtube (or vimeo). In our new tutorial I will tell you how you can create youtube cross-uploader for your website.

In order to achieve our idea we will use
YouTube API v2.0 – Browser-based Uploading. In the beginning, we should prepare our own access token key. OAuth will help us with it. Then, we will display a form, where user can enters the video details (like title, category, description and keywords). When we have sent this information, Youtube will return us temporary upload token and url. Once we get it – we can start upload of selected video file.

Please pay attention, in the most beginning, you should create your own product in order to create your youtube developer key. So, please go to this page and make your own key, and after – put your key here: $sDevKey = ‘Your Youtube Developer Key’;

I hope that my code is easy enough. All the process is separated into three logical steps: get access token, send video info and receive upload token, and upload video file. That’s all.