Reputation: 999
I'm using Google API's PHP client library and when I use this solution:
https://stackoverflow.com/a/14552052/1181479 and the same as here https://developers.google.com/youtube/v3/code_samples/php#resumable_uploads
witch contain such logic:
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);
}
The main problem is this error:
ErrorException [ Recoverable Error ]: Argument 1 passed to Google_MediaFileUpload::nextChunk() must be an instance of Google_HttpRequest, instance of Google_Video given, called in /opt/code/host/resulinkpro/www/application/classes/Controller/Upload.php on line 132 and defined
the core of that stuff is: $media is Google_Video class and
$media->nextChunk($result, $chunk);
requires $result to be Google_HttpRequest SO Google documentation and any example in web will not help to achieve that task at all! Last chance on you guys! Thank you!
Upvotes: 0
Views: 719
Reputation: 12877
Both of the examples were made for PHP client 0.6.3, I believe you are trying it with 1.0 version. You can read about migrating here.
We hope to post the updated examples really soon.
Upvotes: 2