Search for media assets

更新时间:
复制 MD 格式

You can use a server-side SDK to call the SearchMedia operation and search for media assets in Intelligent Media Services. This topic provides sample code in Java.

Usage notes

You can filter media assets by title, media asset ID, classification, and status. You can also specify the sort field and sort order for the results.

Sample code

You can debug this operation online in the Alibaba Cloud OpenAPI Developer Portal.

<?php

require_once '../vendor/autoload.php';

use AlibabaCloud\SDK\ICE\V20201109\ICE;
use AlibabaCloud\SDK\ICE\V20201109\Models;
use AlibabaCloud\SDK\ICE\V20201109\Models\SearchMediaRequest;
use Darabonba\OpenApi\Models\Config;

try {

    // An Alibaba Cloud account AccessKey has all API access permissions. Use a Resource Access Management (RAM) user for API calls and daily O&M.
    // This example shows how to store an AccessKey ID and AccessKey secret in environment variables. For more information about how to configure environment variables, see https://help.aliyun.com/document_detail/311677.html
    $credential = new Credential([]);
    $config = new Config([
     'credential' => $credential,
     'endpoint' => 'ice.cn-shanghai.aliyuncs.com'
    ]);
    // To hard-code the AccessKey ID and AccessKey secret, use the following code. Do not hard-code the AccessKey ID and AccessKey secret in your project code. Hard coding may cause an AccessKey leak and threaten the security of all resources in your account.
    // $config->accessKeyId = '<yourAccessKeyId>';
    // $config->accessKeySecret = '<yourAccessKeySecret>';
    $client = new ICE($config);

    // Search for media assets
    $request = new SearchMediaRequest();
    $request->match = "fullText = 'China'";
    $response = $client->SearchMedia($request);
    var_dump($response);

} catch (TeaUnableRetryError $e) {
    var_dump($e->getMessage());
    var_dump($e->getErrorInfo());
    var_dump($e->getLastException());
    var_dump($e->getLastRequest());
}

Related API operation

SearchMedia - Searches for media information