我试图在创建播放列表时设置缩略图,我这样做:
// 1. Create the snippet for the playlist. Set its title and description.
$playlistSnippet = new Google_Service_YouTube_PlaylistSnippet();
$playlistSnippet->setTitle('Test Playlist ' . date("Y-m-d H:i:s"));
$playlistSnippet->setDescription('A private playlist created with the YouTube API v3');
$playlistSnippet->setThumbnails ('https://www.google.co.ve/url?sa=i&rct=j&q=&esrc=s&source=imgres&cd=&cad=rja&uact=8&ved=0ahUKEwidvaDtwbPTAhVhKpoKHWf5CboQjRwIBw&url=http%3A%2F%2Fimagenesbonitas.bosquedefantasias.com%2F&psig=AFQjCNHfcV6nKOO6oU7iwv3LCfb6GBFkAg&ust=1492794187290336');
但问题是播放列表中的缩略图是:
"thumbnails": {
(key): {
"url": string,
"width": unsigned integer,
"height": unsigned integer
}
所以我不知道如何创建这种方式的对象,然后将其添加到代码段对象。
答案 0 :(得分:0)
setThumbnails
的完整原型是:
setThumbnails(Google_Service_YouTube_ThumbnailDetails $thumbnails)
Google_Service_YouTube_ThumbnailDetails
有以下方法:
setDefault( Google_Service_YouTube_Thumbnail $default )
setHigh( Google_Service_YouTube_Thumbnail $high )
setMaxres( Google_Service_YouTube_Thumbnail $maxres )
setMedium( Google_Service_YouTube_Thumbnail $medium )
setStandard( Google_Service_YouTube_Thumbnail $standard )
Google_Service_YouTube_Thumbnail
的方法:
setHeight( mixed $height )
setUrl( mixed $url )
setWidth( mixed $width )
以下内容可用于设置缩略图:
$thumbnailDetails = new Google_Service_YouTube_ThumbnailDetails();
$thumbnail = new Google_Service_YouTube_Thumbnail();
$thumbnail->setUrl("https://example.com/image.jpg");
$thumbnail->setHeight(720);
$thumbnail->setWidth(1280);
thumbnailDetails->setDefault($thumbnail);
$playlistSnippet->setThumbnails($thumbnailDetails);