- How does it work
- Create your Google API App
- Get your App Credentials
- Script Installation
- Running the Script
- Credits and Resources
YouTube Video Uploader 3.0 is a YouTube API-based PHP script that lets you add YouTube uploading functionality to your own website or web application. It allows your users to upload videos directly to your own YouTube Channel, without the need to sign in to YouTube or even have Google Account. The script uses the latest version (3.0) of YouTube Application Programming Interface (API) to upload videos and and set the video's metadata (title, description, tags, status, and category). The script uses Google OAuth 2.0 endpoints to create web server application that use OAuth 2.0 authorization to access Google APIs. OAuth 2.0 allows you to share specific data with an application while keeping your Google Account usernames, passwords, and other information private.
While videos are being uploaded, progress bar show the current video upload progress so your users don’t have to second guess how long uploading videos is going to take.You can also set video file size limit and video types with ease to ensure your website is free from abuse.
To make this script work, you’ll need to create and authorize an app in Google Developer Console at https://console.developers.google.com (very easy, see instructions).You can integrate this script in any application with minimum effort and without the need to use MySQL unless you need to save user's logs and info.
- Upload videos directly from user's browser to your YouTube channel without the need to worry about your account credentials.
- Uses the latest version (3.0) of YouTube Application Programming Interface (API) to upload videos and and set the video's metadata.
- Many aspects of the script are fully customizable, allowing you the freedom to create an uploader that does exactly what you need it to. In addition, you need to add just two lines of code in your pages to integrate the video uploader.
- HTML5 file uploader for ultimate compatibility.
- Real-time uploading progress bar indicator, so users do not have to second guess how long uploading files is going to take.
- Set video size limits and video type limits with ease to PASS/GET video data.
- Ease of workflow and usability for the application.
Video Uploader 3.0 was designed to make implementation as easy as possible. Before purchasing or implementing, make sure you meet the minimum requirements:
4. How does it work?
Actually, your server, not the user, who authorize and upload video to your YouTube channel, not the user. The user only upload the video to a temporarily directory in your server.
- The client part of Video Uploader 3.0 acquires the video from user and uploads it to your server temporarily.
- The YouTube Data API supports the OAuth 2.0 protocol for authorizing access to your YouTube account via the application Key. When the script first attempts to upload video to YouTube account, Video Uploader 3.0 initiates the OAuth 2.0 authorization process.
- The script then uses YouTube API to upload the video from your server to your YouTube channel.
5. Create your Google API App
- Sign-up for a new Google account if you do not have an account yet, or if you need to have separate account for your Video Uploader 3.0 (recommended).
- Sign-in to your Google account then go to Google Developer Console at https://console.developers.google.com, then "Enable and manage APIs" in the Getting Started page.
- Enter your project name (it could be anything, like My Video Uploader) and click "Create" button.
- A project will be created and you will be forwarded to the API Manager page below. If not, open the left-hand side menu then click on the API Manager link.
- A page with a list of Popular APIs categories appears as shown below. Under "YouTube APIs" category click in the first link "YouTube Data API" then click the "Enable" button at the top-left of the page to enable YouTube Data API v3.
Watch on YouTube
6. Get your App Credentials
- Click "Go to Credentials" button, or "Credentials" link in the left-hand API Manager menu. Click "Create Credentials" drop-down menu then select the first option (API key).
- A new dialogue box titled "Create a new key" pops-up with four options. Click "Server key" option. In the "Name" text box enter any name for your application (e.g., viduploader3) and leave the IP address empty (you can update later for secure ). Click create button to finish.
- A pop-up box appears with your API key.
- Click the "OAuth consent screen" tab at the top and enter "Product name shown to users" (it could be anything, like viduploader3).
- Once again (the same as step 1), click on the "Create Credentials" drop-down menu then select the second option (OAuth client ID). A list of types of applications will be displays. Select the first application type (Web application) and enter any name for your Web application (e.g., viduploader3).
Change "example.com" to your server address or domain name and make any changes to point to "viduploader3" directory in your server if necessary. This is very important to get your script work.
- Click "Create" button to finish and get your OAuth client. A pop-up box appears with your "client ID" and "client secret".
7. Script Installation
These steps will be done once only:
- Unzip the viduploader3.zip to the root directory or any other directory in your server. A new directory (/viduploader3) will be created with the following structure and files:
Load install.php file in your browser (example: http://example.com/viduploader3/install.php).
- Fill out the installation form with your API credentials and click install button. You will be prompted to confirm login using the same account you have just used to create the API app. Click "Allow" button to complete installation. (happen for ONE tine only).
If authorization was successfull, you will be directed to the video upload form to uplod your first video (example: http://example.com/viduploader3)
8. Running the Script
- Load http://example.com/viduploader3 in your browser
- Completing all form fields are mandatory according to the form validation options.
- Select the video you need to upload the click the Upload button and watch the uploading progress bar.
- If upload is successful, you will be redirected to viduploader3/videopage.php which could be any page in your server to PASS, display or save to MySQL the video data (e.g., key, title, description, etc.), update user's records, or notify the site admin for new uploads.
- If you need to integrate the form in any of your existing pages (e.g., mypage.php) just add the following two lines:
// in the head section of your page
<?php include ("uploader_head.php"); ?>
// in the body of your page and where you need to show the upload form
<?php include("uploader_form.php"); ?>
- It is very recommended to place the page in which you need to integrate the form (mypage.php) inside the viduploader3 directory to avoid any errors, at least at the beginning and until you get familiar with the script structure.
Two form options are founded in the viduploader3/uploader_form.php file: video file size and video type. Other options should NOT be changed:
'fileSizeLimit' : '1024 MB' // other examples: '1000 KB'or '1 GB' ,
'fileType' : ['video/x-ms-wmv', 'video/mp4', 'video/x-msvideo', 'video/x-sgi-movie', 'video/x-flv', 'video/webm', 'video/3gpp'],
Many video data are found in viduploader3/upload_to_youtube/processing.php and can be processed for saving or passing to other pages:
11. Credits and Resources
- YouTube Data API Reference
- Google APIs Client Library for PHP
- PHP Server-Side YouTube V3 OAuth API Video Upload Guide (Special thanks to Dom Sammut)