You need to enable JavaScript to run this app.
导航

媒资管理

最近更新时间2023.11.21 19:30:46

首次发布时间2021.02.23 10:42:39

本文为您提供了服务端 PHP SDK 的媒资管理模块相关的 API 调用示例。主要包含:查询媒资信息、修改媒资信息、修改媒资发布状态、获取音视频列表、获取字幕文件和媒资分类等。

初始化

使用前请先完成初始化,参考初始化

查询媒资信息

接口请求参数和返回参数详见 OpenAPI:查询媒资信息

<?php
require('../../vendor/autoload.php');

$client = Volc\Service\Vod\Vod::getInstance();
$client->setAccessKey('your ak');
$client->setSecretKey('your sk');

$request = new Volc\Service\Vod\Models\Request\VodGetMediaInfosRequest();
$request->setVids("your Vids");


$response = new Volc\Service\Vod\Models\Response\VodGetMediaInfosResponse();
try {
    $response = $client->getMediaInfos($request);
} catch (Exception $e) {
    echo $e, "\n";
} catch (Throwable $e) {
    echo $e, "\n";
}
if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) {
    echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n";
} else {
    echo $response->serializeToJsonString(), "\n";
}

修改媒资信息

接口请求参数和返回参数详见 OpenAPI:修改媒资信息

<?php
require('../../vendor/autoload.php');

$client = Volc\Service\Vod\Vod::getInstance();
$client->setAccessKey('your ak');
$client->setSecretKey('your sk');

$request = new Volc\Service\Vod\Models\Request\VodUpdateMediaInfoRequest();
$request->setVid("your Vid");
$request->setPosterUriUnwrapped("your PosterUri");
$request->setTitleUnwrapped("your Title");
$request->setDescriptionUnwrapped("your Description");
$request->setTagsUnwrapped("your Tags");
$request->setClassificationIdUnwrapped(0);


$response = new Volc\Service\Vod\Models\Response\VodUpdateMediaInfoResponse();
try {
    $response = $client->updateMediaInfo($request);
} catch (Exception $e) {
    echo $e, "\n";
} catch (Throwable $e) {
    echo $e, "\n";
}
if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) {
    echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n";
} else {
    echo $response->serializeToJsonString(), "\n";
}

修改媒资发布状态

接口请求参数和返回参数详见OpenAPI:修改媒资发布状态

<?php
require('../../vendor/autoload.php');

$client = Volc\Service\Vod\Vod::getInstance();
$client->setAccessKey('your ak');
$client->setSecretKey('your sk');

$request = new Volc\Service\Vod\Models\Request\VodUpdateMediaPublishStatusRequest();
$request->setVid("your Vid");
$request->setStatus("your Status");


$response = new Volc\Service\Vod\Models\Response\VodUpdateMediaPublishStatusResponse();
try {
    $response = $client->updateMediaPublishStatus($request);
} catch (Exception $e) {
    echo $e, "\n";
} catch (Throwable $e) {
    echo $e, "\n";
}
if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) {
    echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n";
} else {
    echo $response->serializeToJsonString(), "\n";
}

获取封面候选结果

接口请求参数和返回参数详见 OpenAPI:获取封面候选结果

<?php
require('../../vendor/autoload.php');

$client = Volc\Service\Vod\Vod::getInstance();
$client->setAccessKey('your ak');
$client->setSecretKey('your sk');

$request = new Volc\Service\Vod\Models\Request\VodGetRecommendedPosterRequest();
$request->setVids("your Vids");


$response = new Volc\Service\Vod\Models\Response\VodGetRecommendedPosterResponse();
try {
    $response = $client->getRecommendedPoster($request);
} catch (Exception $e) {
    echo $e, "\n";
} catch (Throwable $e) {
    echo $e, "\n";
}
if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) {
    echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n";
} else {
    echo $response->serializeToJsonString(), "\n";
}

批量删除完整媒资

接口请求参数和返回参数详见 OpenAPI:批量删除完整媒资

<?php
require('../../vendor/autoload.php');

$client = Volc\Service\Vod\Vod::getInstance();
$client->setAccessKey('your ak');
$client->setSecretKey('your sk');

$request = new Volc\Service\Vod\Models\Request\VodDeleteMediaRequest();
$request->setVids("your Vids");
$request->setCallbackArgs("your CallbackArgs");


$response = new Volc\Service\Vod\Models\Response\VodDeleteMediaResponse();
try {
    $response = $client->deleteMedia($request);
} catch (Exception $e) {
    echo $e, "\n";
} catch (Throwable $e) {
    echo $e, "\n";
}
if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) {
    echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n";
} else {
    echo $response->serializeToJsonString(), "\n";
}

删除媒体文件

接口请求参数和返回参数详见 OpenAPI:删除媒体文件

<?php
require('../../vendor/autoload.php');

$client = Volc\Service\Vod\Vod::getInstance();
$client->setAccessKey('your ak');
$client->setSecretKey('your sk');

$request = new Volc\Service\Vod\Models\Request\VodDeleteTranscodesRequest();
$request->setVid("your Vid");
$request->setFileIds("your FileIds");
$request->setCallbackArgs("your CallbackArgs");


$response = new Volc\Service\Vod\Models\Response\VodDeleteTranscodesResponse();
try {
    $response = $client->deleteTranscodes($request);
} catch (Exception $e) {
    echo $e, "\n";
} catch (Throwable $e) {
    echo $e, "\n";
}
if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) {
    echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n";
} else {
    echo $response->serializeToJsonString(), "\n";
}

获取音视频列表

接口请求参数和返回参数详见 OpenAPI:获取音视频列表

<?php
require('../../vendor/autoload.php');

$client = Volc\Service\Vod\Vod::getInstance();
$client->setAccessKey('your ak');
$client->setSecretKey('your sk');

$request = new Volc\Service\Vod\Models\Request\VodGetMediaListRequest();
$request->setSpaceName("your SpaceName");
$request->setVid("your Vid");
$request->setStatus("your Status");
$request->setOrder("your Order");
$request->setTags("your Tags");
$request->setStartTime("your StartTime");
$request->setEndTime("your EndTime");
$request->setOffset("your Offset");
$request->setPageSize("your PageSize");
$request->setClassificationIds("your ClassificationIds");
$request->setTosStorageClasses("your TosStorageClasses");
$request->setVodUploadSources("your VodUploadSources");


$response = new Volc\Service\Vod\Models\Response\VodGetMediaListResponse();
try {
    $response = $client->getMediaList($request);
} catch (Exception $e) {
    echo $e, "\n";
} catch (Throwable $e) {
    echo $e, "\n";
}
if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) {
    echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n";
} else {
    echo $response->serializeToJsonString(), "\n";
}

获取字幕文件

接口请求参数和返回参数详见 OpenAPI:获取字幕文件

<?php
require('../../vendor/autoload.php');

$client = Volc\Service\Vod\Vod::getInstance();
$client->setAccessKey('your ak');
$client->setSecretKey('your sk');

$request = new Volc\Service\Vod\Models\Request\VodGetSubtitleInfoListRequest();
$request->setVid("your Vid");
$request->setFileIds("your FileIds");
$request->setLanguages("your Languages");
$request->setFormats("your Formats");
$request->setLanguageIds("your LanguageIds");
$request->setSubtitleIds("your SubtitleIds");
$request->setStatus("your Status");
$request->setTitle("your Title");
$request->setTag("your Tag");
$request->setOffset("your Offset");
$request->setPageSize("your PageSize");
$request->setSsl("your Ssl");


$response = new Volc\Service\Vod\Models\Response\VodGetSubtitleInfoListResponse();
try {
    $response = $client->getSubtitleInfoList($request);
} catch (Exception $e) {
    echo $e, "\n";
} catch (Throwable $e) {
    echo $e, "\n";
}
if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) {
    echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n";
} else {
    echo $response->serializeToJsonString(), "\n";
}

修改字幕发布状态

接口请求参数和返回参数详见 OpenAPI:修改字幕发布状态

<?php
require('../../vendor/autoload.php');

$client = Volc\Service\Vod\Vod::getInstance();
$client->setAccessKey('your ak');
$client->setSecretKey('your sk');

$request = new Volc\Service\Vod\Models\Request\VodUpdateSubtitleStatusRequest();
$request->setVid("your Vid");
$request->setFileIds("your FileIds");
$request->setLanguages("your Languages");
$request->setFormats("your Formats");
$request->setStatus("your Status");


$response = new Volc\Service\Vod\Models\Response\VodUpdateSubtitleStatusResponse();
try {
    $response = $client->updateSubtitleStatus($request);
} catch (Exception $e) {
    echo $e, "\n";
} catch (Throwable $e) {
    echo $e, "\n";
}
if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) {
    echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n";
} else {
    echo $response->serializeToJsonString(), "\n";
}

修改字幕信息

接口请求参数和返回参数详见 OpenAPI:获取字幕信息

<?php
require('../../vendor/autoload.php');

$client = Volc\Service\Vod\Vod::getInstance();
$client->setAccessKey('your ak');
$client->setSecretKey('your sk');

$request = new Volc\Service\Vod\Models\Request\VodUpdateSubtitleInfoRequest();
$request->setVid("your Vid");
$request->setFileId("your FileId");
$request->setLanguage("your Language");
$request->setFormat("your Format");
$request->setTitleUnwrapped("your Title");
$request->setTagUnwrapped("your Tag");


$response = new Volc\Service\Vod\Models\Response\VodUpdateSubtitleInfoResponse();
try {
    $response = $client->updateSubtitleInfo($request);
} catch (Exception $e) {
    echo $e, "\n";
} catch (Throwable $e) {
    echo $e, "\n";
}
if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) {
    echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n";
} else {
    echo $response->serializeToJsonString(), "\n";
}

获取截图结果

接口请求参数和返回参数详见 OpenAPI:获取截图结果

<?php
require('../../vendor/autoload.php');

$client = Volc\Service\Vod\Vod::getInstance();
$client->setAccessKey('your ak');
$client->setSecretKey('your sk');

$request = new Volc\Service\Vod\Models\Request\VodListSnapshotsRequest();
$request->setVid("your Vid");


$response = new Volc\Service\Vod\Models\Response\VodListSnapshotsResponse();
try {
    $response = $client->listSnapshots($request);
} catch (Exception $e) {
    echo $e, "\n";
} catch (Throwable $e) {
    echo $e, "\n";
}
if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) {
    echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n";
} else {
    echo $response->serializeToJsonString(), "\n";
}

创建视频分类

接口请求参数和返回参数详见 OpenAPI:创建视频分类

<?php
require('../../vendor/autoload.php');

$client = Volc\Service\Vod\Vod::getInstance();
$client->setAccessKey('your ak');
$client->setSecretKey('your sk');

$request = new Volc\Service\Vod\Models\Request\VodCreateVideoClassificationRequest();
$request->setSpaceName("your SpaceName");
$request->setLevel(0);
$request->setParentId(0);
$request->setClassification("your Classification");


$response = new Volc\Service\Vod\Models\Response\VodCreateVideoClassificationResponse();
try {
    $response = $client->createVideoClassification($request);
} catch (Exception $e) {
    echo $e, "\n";
} catch (Throwable $e) {
    echo $e, "\n";
}
if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) {
    echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n";
} else {
    echo $response->serializeToJsonString(), "\n";
}

查询视频分类

接口请求参数和返回参数详见 OpenAPI:查询视频分类

<?php
require('../../vendor/autoload.php');

$client = Volc\Service\Vod\Vod::getInstance();
$client->setAccessKey('your ak');
$client->setSecretKey('your sk');

$request = new Volc\Service\Vod\Models\Request\VodListVideoClassificationsRequest();
$request->setSpaceName("your SpaceName");
$request->setClassificationId(0);


$response = new Volc\Service\Vod\Models\Response\VodListVideoClassificationsResponse();
try {
    $response = $client->listVideoClassifications($request);
} catch (Exception $e) {
    echo $e, "\n";
} catch (Throwable $e) {
    echo $e, "\n";
}
if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) {
    echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n";
} else {
    echo $response->serializeToJsonString(), "\n";
}

更新视频分类

接口请求参数和返回参数详见 OpenAPI:更新视频分类

<?php
require('../../vendor/autoload.php');

$client = Volc\Service\Vod\Vod::getInstance();
$client->setAccessKey('your ak');
$client->setSecretKey('your sk');

$request = new Volc\Service\Vod\Models\Request\VodUpdateVideoClassificationRequest();
$request->setSpaceName("your SpaceName");
$request->setClassificationId(0);
$request->setClassification("your Classification");


$response = new Volc\Service\Vod\Models\Response\VodUpdateVideoClassificationResponse();
try {
    $response = $client->updateVideoClassification($request);
} catch (Exception $e) {
    echo $e, "\n";
} catch (Throwable $e) {
    echo $e, "\n";
}
if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) {
    echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n";
} else {
    echo $response->serializeToJsonString(), "\n";
}

删除视频分类

接口请求参数和返回参数详见 OpenAPI:删除视频分类

<?php
require('../../vendor/autoload.php');

$client = Volc\Service\Vod\Vod::getInstance();
$client->setAccessKey('your ak');
$client->setSecretKey('your sk');

$request = new Volc\Service\Vod\Models\Request\VodDeleteVideoClassificationRequest();
$request->setSpaceName("your SpaceName");
$request->setClassificationId(0);


$response = new Volc\Service\Vod\Models\Response\VodDeleteVideoClassificationResponse();
try {
    $response = $client->deleteVideoClassification($request);
} catch (Exception $e) {
    echo $e, "\n";
} catch (Throwable $e) {
    echo $e, "\n";
}
if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) {
    echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n";
} else {
    echo $response->serializeToJsonString(), "\n";
}

修改媒资存储类型

接口请求参数和返回参数详见 OpenAPI:修改媒资存储类型

<?php
require('../../vendor/autoload.php');

$client = Volc\Service\Vod\Vod::getInstance();
$client->setAccessKey('your ak');
$client->setSecretKey('your sk');

$request = new Volc\Service\Vod\Models\Request\VodUpdateMediaStorageClassRequest();
$request->setVids("your Vids");
$request->setStorageClass("your StorageClass");
$request->setCallbackArgs("your CallbackArgs");
$request->setFileIds("your FileIds");

$response = new Volc\Service\Vod\Models\Response\VodUpdateMediaStorageClassResponse();
try {
    $response = $client->updateMediaStorageClass($request);
} catch (Exception $e) {
    echo $e, "\n";
} catch (Throwable $e) {
    echo $e, "\n";
}
if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) {
    echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n";
} else {
    echo $response->serializeToJsonString(), "\n";
}

根据文件路径获取媒资信息列表

接口请求参数和返回参数详见 OpenAPI:根据文件路径获取媒资信息列表

<?php
require('../../vendor/autoload.php');

$client = Volc\Service\Vod\Vod::getInstance();
$client->setAccessKey('your ak');
$client->setSecretKey('your sk');

$request = new Volc\Service\Vod\Models\Request\VodListFileMetaInfosByFileNamesRequest();
$request->setSpaceName("your SpaceName");
$request->setFileNameEncodeds("your FileNameEncodeds");
$request->setBucketName("your BucketName");


$response = new Volc\Service\Vod\Models\Response\VodListFileMetaInfosByFileNamesResponse();
try {
    $response = $client->listFileMetaInfosByFileNames($request);
} catch (Exception $e) {
    echo $e, "\n";
} catch (Throwable $e) {
    echo $e, "\n";
}
if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) {
    echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n";
} else {
    echo $response->serializeToJsonString(), "\n";
}