4

i'm trying (php) to upload a video (browser based not storing video in my app want to upload straight to youtube).

I cant find any docs on this. Eg like this https://developers.google.com/youtube/2.0/developers_guide_php#Browser_based_Upload

But for v3.0 i'm looking at the code that is provided (3.0) but cant see a way to get video (ie $videoPath = "/path/to/file.mp4") without storing (temporarily in my app).

// REPLACE with the path to your file that you want to upload
$videoPath = "/path/to/file.mp4";

// Create a snipet with title, description, tags and category id
$snippet = new Google_VideoSnippet();
$snippet->setTitle("Test title");
$snippet->setDescription("Test description");
$snippet->setTags(array("tag1", "tag2"));

1 Answer 1

7

There's now support for resumable uploads using CORS in the YouTube Data API v3.

A rough, but working, example at https://youtube-api-samples.googlecode.com/git/yt-upload-javascript/index.html (source files at https://code.google.com/p/youtube-api-samples/source/browse/#git%2Fyt-upload-javascript) that shows the upload flow, using the Google+ sign-in button to handle OAuth 2 (you can use the normal OAuth 2 browser client flow if you'd prefer) and with a progress indicator. It also shows how you could poll for video processing status following an upload and embed the resulting video on a page once it's been processed.

Sign up to request clarification or add additional context in comments.

4 Comments

.NET version of this?
How would you use the OAuth 2 browser client flow? I have a refresh token etc stored in a database so i would like to use that instead of signing into google each time
This is a nice example, but as the readme says: The code samples at code.google.com/p/youtube-api-samples are no longer being maintained. Please update your code samples from the following GitHub repository: github.com/youtube/api-samples
Yes, I just checked in a new code sample, will be published to github soon. It's based on github.com/googledrive/cors-upload-sample

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.