2014-08-28 67 views
0

我試圖將視頻類型更改爲沿着YouTube頻道更新API關聯網站,但只更新了自定義文本。我得到的通知錯誤對Google_Service_YouTube_InvideoPromotion的重載元素進行間接修改沒有任何效果

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? 

回答

0

下面是詳細的更新代碼更新項目

$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; 
0

我得到了同樣的問題如上所述,這裏就是我設法使它工作:

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; 
} 

希望有幫助...

相關問題