標(biāo)簽管理
更新時間:
媒體庫不提供全局的標(biāo)簽管理和設(shè)置,每個媒體的標(biāo)簽都是獨(dú)立的。本文為您介紹如何為媒體文件添加和刪除標(biāo)簽。
功能使用
媒體處理支持通過SDK或API管理標(biāo)簽。SDK安裝請參見Java SDK、Python SDK、PHP SDK,示例代碼見下文。如需通過API使用功能,請參見直接調(diào)用API管理標(biāo)簽。
說明
本文以PHP語言為例。
SDK調(diào)用API管理標(biāo)簽
添加標(biāo)簽
標(biāo)簽的API支持單個標(biāo)簽的添加和刪除,如果要一次設(shè)置多個標(biāo)簽,可以通過更新媒體-基本信息實(shí)現(xiàn)。添加標(biāo)簽的詳細(xì)參數(shù)說明請參見更新媒體-添加標(biāo)簽,示例代碼如下:
<?php namespace AlibabaCloud\SDK\Sample; use AlibabaCloud\SDK\Mts\V20140618\Mts; use AlibabaCloud\Darabonba\Env\Env; use AlibabaCloud\Tea\Tea; use AlibabaCloud\Tea\Utils\Utils; use AlibabaCloud\Tea\Console\Console; use Darabonba\OpenApi\Models\Config; use AlibabaCloud\SDK\Mts\V20140618\Models\AddMediaTagRequest; class Sample { /** * @param string $accessKeyId * @param string $accessKeySecret * @param string $regionId * @return Mts * 正式環(huán)境下 建議 protocol = "HTTPS"; */ public static function createClient($accessKeyId, $accessKeySecret, $regionId){ $config = new Config([]); $config->accessKeyId = $accessKeyId; $config->accessKeySecret = $accessKeySecret; $config->regionId = $regionId; $config->protocol = "HTTP"; return new Mts($config); } /** * @return void */ public static function main(){ $client = self::createClient(Env::getEnv("ALIBABA_CLOUD_ACCESS_KEY_ID"), Env::getEnv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"), 'cn-shanghai'); $request = new AddMediaTagRequest([ "mediaId" => "3e6149d5ad2dc3e4******", "tag" => "tag1" ]); $response = $client->addMediaTag($request); Console::log(Utils::toJSONString(Tea::merge($response->body))); } } $path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php'; if (file_exists($path)) { require_once $path; } Sample::main();
刪除標(biāo)簽
<?php namespace AlibabaCloud\SDK\Sample; use AlibabaCloud\SDK\Mts\V20140618\Mts; use AlibabaCloud\Darabonba\Env\Env; use AlibabaCloud\Tea\Tea; use AlibabaCloud\Tea\Utils\Utils; use AlibabaCloud\Tea\Console\Console; use Darabonba\OpenApi\Models\Config; use AlibabaCloud\SDK\Mts\V20140618\Models\DeleteMediaTagRequest; class Sample { /** * @param string $accessKeyId * @param string $accessKeySecret * @param string $regionId * @return Mts * 正式環(huán)境下 建議 protocol = "HTTPS"; */ public static function createClient($accessKeyId, $accessKeySecret, $regionId){ $config = new Config([]); $config->accessKeyId = $accessKeyId; $config->accessKeySecret = $accessKeySecret; $config->regionId = $regionId; $config->protocol = "HTTP"; return new Mts($config); } /** * @return void */ public static function main(){ $client = self::createClient(Env::getEnv("ALIBABA_CLOUD_ACCESS_KEY_ID"), Env::getEnv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"), 'cn-shanghai'); $request = new DeleteMediaTagRequest([ "mediaId" => "3e6149d5ad2dc3e4******", "tag" => "tag1" ]); $response = $client->deleteMediaTag($request); Console::log(Utils::toJSONString(Tea::merge($response->body))); } } $path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php'; if (file_exists($path)) { require_once $path; } Sample::main();
直接調(diào)用API管理標(biāo)簽
說明
直接調(diào)用API是指直接在OpenAPI門戶調(diào)用該接口對標(biāo)簽進(jìn)行管理。
下表為標(biāo)簽管理對應(yīng)的接口。
功能 | 接口 |
添加標(biāo)簽 | |
刪除標(biāo)簽 |
文檔內(nèi)容是否對您有幫助?