使用PHP客户端库v3将视频上传到youtube [英] Upload video to youtube using php client library v3

查看:115
本文介绍了使用PHP客户端库v3将视频上传到youtube的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用客户端库v3将视频上传到youtube.

I am trying to upload a video to youtube using client library v3.

v3库是实验性的,没有太多的文档 (提供的示例不包括youtube)

The v3 library is experimental and does not have much documentation (samples provided does not include youtube)

我已经使用oauth 2.0正确验证了用户身份.当我有访问令牌时,我正在尝试使用此代码.

I have properly authenticated user with oauth 2.0. And when I have access token, I am trying with this code.

if ($client->getAccessToken()) {
    $snippet = new Google_VideoSnippet();
    $snippet -> setTitle = "Demo title";
    $snippet -> setDescriptio = "Demo descrition";
    $snippet -> setTags = array("tag1","tag2");
    $snippet -> setMimeType = 'video/quicktime';

    $video = new Google_Video();
    $video -> setSnippet($snippet);

    // Not sure what to do now....

    $_SESSION['access_token'] = $client->getAccessToken();
}

文档

我需要提供一个 part 参数

The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include.

The part names that you can include in the parameter value are snippet, contentDetails, player, statistics, status, and topicDetails. However, not all of those parts contain properties that can be set when setting or updating a video's metadata. For example, the statistics object encapsulates statistics that YouTube calculates for a video and does not contain values that you can set or modify. If the parameter value specifies a part that does not contain mutable values, that part will still be included in the API response.

但是它缺少文档,除了我无法理解的python示例. (示例位于我提供的链接的底部)

But it lacks documentation except a python example which I am not able to understand. (the example is at the bottom of the link , I provided)

请不要给zend库提供示例/链接,它使用了我不需要的auth-sub. 我想使用oauth 2.0.

Please, dont give example/links to zend library, it uses auth-sub which I dont want. I want to use oauth 2.0.

推荐答案

上传视频的代码如下.

$youtubeService->videos->insert($part, Google_Video $postBody, $optParams = array());

'part'是您希望请求返回的内容.在这种情况下,它可能只是status,它返回有关上载状态的信息.

'part' is what you want the request to return. In this case that could just be status, which return information about the status of the upload.

Google PHP客户端库的发行版可能很旧,因此您需要在 https://code.google.com/p/google-api-php-client/

The release of the Google PHP client library might be old, so you'll want to checkout the source at https://code.google.com/p/google-api-php-client/

这篇关于使用PHP客户端库v3将视频上传到youtube的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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