智能封面模板接口

最近更新时间:2023-11-23 19:42:43

我的收藏

简介

本文档提供关于智能封面模板接口的 API 概览和 SDK 示例代码。
注意
旧版本可能存在 bug,使用时建议升级到 最新版本
API
操作描述
创建智能封面模板
更新智能封面模板

创建智能封面模板

功能说明

创建智能封面模板。

方法原型

public Guzzle\\Service\\Resource\\Model createMediaSmartCoverTemplate(array $args = array());

请求示例

<?php

require dirname(__FILE__, 2) . '/vendor/autoload.php';

$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的 region 可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
$cosClient = new Qcloud\\Cos\\Client(
array(
'region' => $region,
'scheme' => 'https', //协议头部,默认为http
'credentials'=> array(
'secretId' => $secretId ,
'secretKey' => $secretKey)));
try {
// 创建智能封面模板 https://cloud.tencent.com/document/product/460/84734
$result = $cosClient->createMediaSmartCoverTemplate(array(
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
'Tag' => 'SmartCover',
'Name' => 'media-smartcover-name',
'SmartCover' => array(
'Format' => 'jpg',
'Width' => '1280',
'Height' => '960',
'Count' => '3',
'DeleteDuplicates' => 'true',
),
));
// 请求成功
print_r($result);
} catch (\\Exception $e) {
// 请求失败
echo($e);
}

参数说明

Request 中的具体数据描述如下:
节点名称(关键字)
父节点
描述
类型
是否必选
Tag
Request
模板类型:SmartCover
String
Name
Request
模板名称仅支持中文、英文、数字、_、-和*
String
SmartCover
Request
智能封面参数
Container
Container 类型 SmartCover 的具体数据描述如下:
节点名称(关键字)
父节点
描述
类型
是否必选
默认值
限制
Format
Request.SmartCover
图片格式
String
jpg
jpg、png、webp
Width
Request.SmartCover
String
视频原始宽度
值范围:[128,4096]
单位:px
若只设置 Width 时,按照视频原始比例计算 Height
Height
Request.SmartCover
String
视频原始高度
值范围:[128,4096]
单位:px
若只设置 Height 时,按照视频原始比例计算 Width
Count
Request.SmartCover
截图数量
String
3
[1,10]
DeleteDuplicates
Request.SmartCover
封面去重
String
false
true/false

返回结果示例

GuzzleHttp\\Command\\Result Object
(
[RequestId] => NjRjNzczNjRjMjIxODBfMzUxNGSIOJOIDAJOIDg=
[ContentType] => application/xml
[ContentLength] => 648
[Template] => Array
(
[State] => Normal
[Tag] => SmartCover
[Name] => media-smartcover-name
[BucketId] => examplebucket-1250000000
[Category] => Custom
[TemplateId] => t1616pc7a00f19asf798sd7f89s7f2e646
[UpdateTime] => 2023-07-31T16:39:11+0800
[CreateTime] => 2023-07-31T16:39:11+0800
[SmartCover] => Array
(
[Format] => jpg
[Width] => 1280
[Height] => 960
[Count] => 3
[DeleteDuplicates] => true
)

)

[Bucket] => examplebucket-1250000000
[Location] => examplebucket-1250000000.ci.ap-guangzhou.myqcloud.com/template
)

更新智能封面模板

功能说明

更新智能封面模板。

方法原型

public Guzzle\\Service\\Resource\\Model updateMediaSmartCoverTemplate(array $args = array());

请求示例

<?php

require dirname(__FILE__, 2) . '/vendor/autoload.php';

$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的 region 可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
$cosClient = new Qcloud\\Cos\\Client(
array(
'region' => $region,
'scheme' => 'https', //协议头部,默认为http
'credentials'=> array(
'secretId' => $secretId ,
'secretKey' => $secretKey)));
try {
// 更新智能封面模板 https://cloud.tencent.com/document/product/460/84755
$result = $cosClient->updateMediaSmartCoverTemplate(array(
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
'Key' => '', // TemplateId
'Tag' => 'SmartCover',
'Name' => 'media-smartcover-name',
'SmartCover' => array(
'Format' => 'jpg',
'Width' => '1280',
'Height' => '960',
'Count' => '3',
'DeleteDuplicates' => 'true',
),
));
// 请求成功
print_r($result);
} catch (\\Exception $e) {
// 请求失败
echo($e);
}

参数说明

Request 中的具体数据描述如下:
节点名称(关键字)
父节点
描述
类型
必选
Request
同创建智能封面模板接口的 Request
Container

返回结果示例

GuzzleHttp\\Command\\Result Object
(
[RequestId] => NjRjNzczNjRjMjIxODBfMzUxNGSIOJOIDAJOIDg=
[ContentType] => application/xml
[ContentLength] => 649
[Template] => Array
(
[State] => Normal
[Tag] => SmartCover
[Name] => media-smartcover-name-xxx
[BucketId] => examplebucket-1250000000
[Category] => Custom
[TemplateId] => t1616170pc7a00f19asf798sd7f89s7f2e646
[UpdateTime] => 2023-07-31T16:40:35+0800
[CreateTime] => 2023-07-31T16:39:11+0800
[SmartCover] => Array
(
[Format] => jpg
[Width] => 1280
[Height] => 960
[Count] => 3
[DeleteDuplicates] => true
)

)

[Key] => t1616170pc7a00f19asf798sd7f89s7f2e646
[Bucket] => examplebucket-1250000000
[Location] => examplebucket-1250000000.ci.ap-guangzhou.myqcloud.com/template/t1616170pc7a00f19asf798sd7f89s7f2e646
)