我使用的是Google API的PHP客户端库,当我使用此解决方案时:
https://stackoverflow.com/a/14552052/1181479 和这里一样 https://developers.google.com/youtube/v3/code_samples/php#resumable_uploads
女巫包含这样的逻辑:if ($client->getAccessToken()) {
$videoPath = "path/to/foo.mp4";
$snippet = new Google_VideoSnippet();
$snippet->setTitle("Test title2");
$snippet->setDescription("Test descrition");
$snippet->setTags(array("tag1", "tag2"));
$snippet->setCategoryId("22");
$status = new Google_VideoStatus();
$status->privacyStatus = "private";
$video = new Google_Video();
$video->setSnippet($snippet);
$video->setStatus($status);
$chunkSizeBytes = 1 * 1024 * 1024;
$media = new Google_MediaFileUpload('video/mp4', null, true, $chunkSizeBytes);
$media->setFileSize(filesize($videoPath));
$result = $youtube->videos->insert("status,snippet", $video,
array('mediaUpload' => $media));
$status = false;
$handle = fopen($videoPath, "rb");
while (!$status && !feof($handle)) {
$chunk = fread($handle, $chunkSizeBytes);
$uploadStatus = $media->nextChunk($result, $chunk);
}
fclose($handle);
}
主要问题是这个错误:
ErrorException [可恢复错误]:传递给Google_MediaFileUpload :: nextChunk()的参数1必须是Google_HttpRequest的实例,给出了Google_Video的实例,在/ opt / code / host / resulinkpro / www / application / classes / Controller /中调用第132行上的Upload.php并定义了
那些东西的核心是: $ media 是Google_Video类 和
$media->nextChunk($result, $chunk);
要求 $ result 为Google_HttpRequest所以Google文档和网络上的任何示例都无法完成任务!你最后的机会! 谢谢!