【发布时间】:2018-10-10 00:15:12
【问题描述】:
我尝试更新 YouTube 视频。我在站点https://developers.google.com/youtube/v3/code_samples/php#update_a_video 上使用该函数,并尝试将其复制到我的代码中,但如果我调用listVideos(),我会得到Google_Service_YouTube_VideoListResponse,但我需要一个Google_Service_YouTube_Video。我怎样才能得到它?
我的 PHP 代码:
$youtube = new Google_Service_YouTube($client);
$videoid = "******Video ID********";
$new = "******* TEXT *********";
$videoinfo = $youtube->videos->listVideos('snippet', array('id' => $videoid));
$videoSnippet = $videoinfo[0]['snippet'];
$description = $videoSnippet['description'] . $new;
$videoSnippet['description'] = $description;
$youtube->videos->update("snippet", $videoSnippet);
错误:
: Uncaught TypeError: Argument 2 passed to
Google_Service_YouTube_Resource_Videos::update() must be an instance of
Google_Service_YouTube_Video, instance of
Google_Service_YouTube_VideoSnippet given, called in
P:\Apache24\htdocs\*********** on line 232 and defined in
P:\Apache24\htdocs\*******\Google Api System\vendor\google\apiclient-
services\src\Google\Service\YouTube\Resource\Videos.php:309
Stack trace:
0 P:\Apache24\htdocs\*********: Google_Service_YouTube_Resource_Videos-
>update('snippet', Object(Google_Service_YouTube_VideoSnippet ))
1 P:\Apache24\htdocs\********\*********\index.php(438):
require('P:\\Apache24\\htd...')
【问题讨论】:
-
$videoid = "******视频 ID********;您忘记用 " $videoid = "******视频 ID** 结束******";
-
@g33k 我只在stackoverflow中忘记了它 :) 在我的代码中我写了 $videoid = "******Video ID********";
-
是
$videoid的字面意思是******Video ID********还是就在这里?!
标签: php youtube youtube-api youtube-data-api