內(nèi)容庫(kù)管理
更新時(shí)間:
通過閱讀本文,您可以了解通過服務(wù)端SDK調(diào)用OpenAPI管理智能媒體服務(wù)內(nèi)容庫(kù)的示例代碼。
使用說明
目前僅支持通過OSS文件注冊(cè)媒資內(nèi)容。
示例代碼
您可以通過阿里云OpenAPI開發(fā)者門戶在線調(diào)試。
<?php
require_once '../ice-20201109/autoload.php';
use AlibabaCloud\SDK\ICE\V20201109\ICE;
use AlibabaCloud\SDK\ICE\V20201109\Models;
use AlibabaCloud\SDK\ICE\V20201109\Models\RegisterMediaInfoRequest;
use AlibabaCloud\SDK\ICE\V20201109\Models\GetMediaInfoRequest;
use AlibabaCloud\SDK\ICE\V20201109\Models\UpdateMediaInfoRequest;
use AlibabaCloud\SDK\ICE\V20201109\Models\DeleteMediaInfosRequest;
use AlibabaCloud\SDK\ICE\V20201109\Models\ListMediaBasicInfosRequest;
use Darabonba\OpenApi\Models\Config;
try{
// 阿里云賬號(hào)AccessKey擁有所有API的訪問權(quán)限,建議您使用RAM用戶進(jìn)行API訪問或日常運(yùn)維。
// 本示例以將AccessKey ID和 AccessKey Secret保存在環(huán)境變量為例說明。配置方法請(qǐng)參見:http://bestwisewords.com/document_detail/311677.html
$credential = new Credential([]);
$config = new Config([
'credential' => $credential,
'endpoint' => 'ice.cn-shanghai.aliyuncs.com'
]);
// 如需硬編碼AccessKey ID和AccessKey Secret,代碼如下,但強(qiáng)烈建議不要把AccessKey ID和AccessKey Secret保存到工程代碼里,否則可能導(dǎo)致AccessKey泄露,威脅您賬號(hào)下所有資源的安全。
// $config->accessKeyId = '<yourAccessKeyId>';
// $config->accessKeySecret = '<yourAccessKeySecret>';
$client = new ICE($config);
// 注冊(cè)媒資內(nèi)容
$request = new RegisterMediaInfoRequest();
$request->inputURL = 'http://example-bucket.oss-cn-shanghai.aliyuncs.com/example.mp4';
$request->mediaType = 'audio';
$request->businesstype = 'audio';
$request->title = 'default_title';
$response = $client->registerMediaInfo($request);
var_dump($response);
$mediaId = $response->body->mediaId;
// 獲取單個(gè)內(nèi)容
$request = new GetMediaInfoRequest();
$request->mediaId = $mediaId;
$response = $client->getMediaInfo($request);
var_dump($response);
// 修改內(nèi)容信息
$request = new UpdateMediaInfoRequest();
$request->mediaId = $mediaId;
$request->coverURL = "https://guixin-test-bucket.oss-cn-shanghai.aliyuncs.com/image/timg.jpg";
$response = $client->updateMediaInfo($request);
var_dump($response);
// 刪除內(nèi)容信息
$request = new DeleteMediaInfosRequest();
$request->mediaIds = $mediaId;
$response = $client->deleteMediaInfos($request);
var_dump($response);
// 檢索媒資信息
$request = new ListMediaBasicInfosRequest();
$request->maxResults = 10;
$response = $client->listMediaBasicInfos($request);
var_dump($response);
} catch (TeaUnableRetryError $e) {
var_dump($e->getMessage());
var_dump($e->getErrorInfo());
var_dump($e->getLastException());
var_dump($e->getLastRequest());
}
相關(guān)接口
文檔內(nèi)容是否對(duì)您有幫助?