我正在尝试使用客户端库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();
}
来自文档,
我需要提供 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示例。(我提供的示例是在链接的底部)
请不要给Zend Library的示例/链接,它使用我不想要的auth-sub。我想使用oauth 2.0。
上传视频看起来像这样的代码。
$youtubeService->videos->insert($part, Google_Video $postBody, $optParams = array());
'part'是您想要返回的请求。在这种情况下,可能只是status
,返回有关上传状态的信息。
Google PHP客户端库的发布可能是旧的,因此您需要在https://code.google.com/p/google-api-php-client/
<<