Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用php中的youtube api设置播放列表的缩略图?_Php_Youtube_Youtube Data Api - Fatal编程技术网

如何使用php中的youtube api设置播放列表的缩略图?

如何使用php中的youtube api设置播放列表的缩略图?,php,youtube,youtube-data-api,Php,Youtube,Youtube Data Api,我正在尝试在创建播放列表时为其设置缩略图,我正在执行以下操作: // 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")); $playli

我正在尝试在创建播放列表时为其设置缩略图,我正在执行以下操作:

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

因此,我不知道如何以这种方式创建一个对象,然后将其添加到snippet对象。

setThumbnails的完整原型是:

setThumbnails(Google_Service_YouTube_ThumbnailDetails $thumbnails)
Google\u Service\u YouTube\u 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\u服务\u YouTube\u缩略图
的方法:

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

setThumbnails
的完整原型是:

setThumbnails(Google_Service_YouTube_ThumbnailDetails $thumbnails)
Google\u Service\u YouTube\u 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\u服务\u YouTube\u缩略图
的方法:

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

您知道我是否可以使用blob图像作为图像的url吗?您的意思是将blob数据放在
url
字段中?我不认为这会起作用,因为它需要一个有效的url,但是你可以尝试不使用blob格式。顺便说一句,$playlistiple->setThumbnails(thumbnailDetails);->您忘记了符号“$”。但非常感谢你,这对我很有用。是否有一个页面可供您查阅这些功能?我找到了一个不是官方的,但链接回官方源代码的页面。您知道我是否可以使用blob图像作为图像的url吗?您的意思是将blob数据放在
url
字段中?我不认为这会起作用,因为它需要一个有效的url,但是你可以尝试不使用blob格式。顺便说一句,$playlistiple->setThumbnails(thumbnailDetails);->您忘记了符号“$”。但非常感谢你,这对我很有用。有没有一个页面可以让你查阅这些函数?我找到了一个不是官方的,但链接到官方源代码的页面。