youtube api v3.0 基于浏览器的 php 上传 [英] youtube api v3.0 Browser-based Uploading in php

查看:26
本文介绍了youtube api v3.0 基于浏览器的 php 上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试 (php) 上传视频(基于浏览器的未将视频存储在我的应用程序中想要直接上传到 youtube).

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

我找不到关于此的任何文档.例如像这样 https://developers.google.com/youtube/2.0/developers_guide_php#Browser_based_Upload

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

但是对于 v3.0,我正在查看提供的代码 (3.0) 但看不到获取视频的方法(即 $videoPath = "/path/to/file.mp4")而不存储(暂时在我的应用).

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"));

推荐答案

现在在 YouTube Data API v3 中支持使用 CORS 的可恢复上传.

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

一个粗略但有效的示例,位于 https://youtube-api-samples.googlecode.com/git/yt-upload-javascript/index.html(源文件位于 https://code.google.com/p/youtube-api-samples/source/browse/#git%2Fyt-upload-javascript) 显示上传流程,使用 Google+ 登录按钮处理 OAuth 2(如果您愿意,可以使用普通的 OAuth 2 浏览器客户端流程)并带有进度指示器.它还展示了如何在上传后轮询视频处理状态,并在处理后将生成的视频嵌入到页面中.

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.

这篇关于youtube api v3.0 基于浏览器的 php 上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆