间接修改Google_Service_YouTube_InvideoPromotion的过载元素无效



我试图将类型从视频更改为关联网站,同时更新youtube频道API,但只更新自定义文本。我收到通知错误

try{
$responseChannel['invideoPromotion']['items'][0]['type'] = 'website';
$responseChannel['invideoPromotion']['items'][0]['websiteUrl'] ='http://myassociatewebsite.com/';
$responseChannel['invideoPromotion']['items'][0]['customMessage'] = 'Update tex1';
$updateResponse = $youtube->channels->update('invideoPromotion', $responseChannel);
 }catch (Google_ServiceException $e) {
  $htmlBody .= sprintf('<p>A service error occurred: <code>%s</code></p>',
      htmlspecialchars($e->getMessage()));
}
How to fix that issue please confirm it?

以下是更新项目的确切更新代码

$responseChannel['invideoPromotion']['items'][0]['id']['type'] = 'website';
$responseChannel['invideoPromotion']['items'][0]['id']['websiteUrl'] = 'http://yourassiociatewebsiteurl';
$responseChannel['invideoPromotion']['items'][0]['customMessage'] = 'Click here';
$responseChannel['invideoPromotion']['items'][0]['timing']['type']= 'offsetFromStart';
$responseChannel['invideoPromotion']['items'][0]['timing']['offsetMs']= 100;
$responseChannel['invideoPromotion']['items'][0]['timing']['durationMs']= 10000;

我遇到了与上述相同的问题,以下是我如何使其工作的:

if( !empty($responseChannel['invideoPromotion']['items']) ){
    // This part did not work for me, that's probably because the channel does not have any InvideoPromotion setup yet
    $responseChannel['invideoPromotion']['items'][0]['id']['type'] = 'video';
    $responseChannel['invideoPromotion']['items'][0]['id']['videoId'] = $video_id;
    $responseChannel['invideoPromotion']['items'][0]['customMessage'] = 'Click here';
    $responseChannel['invideoPromotion']['items'][0]['timing']['type']= 'offsetFromStart';
    $responseChannel['invideoPromotion']['items'][0]['timing']['offsetMs']= 100;
    $responseChannel['invideoPromotion']['items'][0]['timing']['durationMs']= 10000;
}else{
    $invideoPromo = new Google_Service_YouTube_InvideoPromotion();
    $ivP_items[] = array(
        'id' => array(
            'type' => 'video',
            'videoId' => $video_id
         ),
        'timing' => array(
            'type' => 'offsetFromStart',
            'offsetMs' => 100,
            'durationMs' => 10000
        )
    );
    $invideoPromo->setItems($ivP_items);
    $responseChannel['invideoPromotion'] = $invideoPromo;
}

希望能有所帮助。。。

相关内容

  • 没有找到相关文章

最新更新