全部产品

内容库管理

本文介绍如何通过ICE PHP SDK进行内容库管理。

注册媒资内容

目前仅支持通过oss文件注册媒资内容,

内容管理

通过SDK对内容进行增删改查操作。

通过 GetMediaInfo 接口获取内容基础信息、文件分析结果、AI分析结果。

通过 ListMediaBasicInfos 接口获取多个内容,支持分页。

代码示例

<?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{

    $config = new Config();
    $config->accessKeyId = "<yourAccessKeyId>";
    $config->accessKeySecret = "<yourAccessKeySecret>";
    $config->regionId = "cn-shanghai";
    $config->endpoint = "ice.cn-shanghai.aliyuncs.com";
    $client = new ICE($config);

    // 注册媒资内容
    $request = new RegisterMediaInfoRequest();
    $request->inputURL = 'http://***.example-bucket.oss-cn-shanghai.aliyuncs.com/***.mp4';
    $request->mediaType = 'video';
    $request->businesstype = 'video';
    $request->title = 'default_title';
    $response = $client->registerMediaInfo($request);
    var_dump($response);
    $mediaId = $response->body->mediaId;

    // 获取单个内容
    $request = new GetMediaInfoRequest();
    $request->mediaId = $mediaId;
    $response = $client->getMediaInfo($request);
    var_dump($response);

    // 修改内容信息
    $request = new UpdateMediaInfoRequest();
    $request->mediaId = $mediaId;
    $request->coverURL = "https://***.example-bucket.oss-cn-shanghai.aliyuncs.com/***.jpg";
    $response = $client->updateMediaInfo($request);
    var_dump($response);

    // 删除内容信息
    $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());
}