0

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

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

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

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();
}

文档中,

我需要提供一个零件参数

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示例之外,它缺少文档。(示例在链接底部,我提供)

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

4

1 回答 1

1

上传视频的代码如下所示。

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

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

Google PHP 客户端库的版本可能已经过时,因此您需要在https://code.google.com/p/google-api-php-client/查看源代码

于 2012-11-01T16:23:02.370 回答