PHP code example of qcloud / vod-dy-php-sdk
1. Go to this page and download the library: Download qcloud/vod-dy-php-sdk library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
qcloud / vod-dy-php-sdk example snippets
encentCloudForDY\Common\Credential;
// 导入可选配置类
use TencentCloudForDY\Common\Profile\ClientProfile;
use TencentCloudForDY\Common\Profile\HttpProfile;
use TencentCloudForDY\Common\Exception\TencentCloudSDKException;
// 导入 vod 产品的 client
use TencentCloudForDY\Vod\V20180717\VodClient;
// 导入要请求接口对应的 Request 类
use TencentCloudForDY\Vod\V20180717\Models\ProcessMediaForDYRequest;
try {
// 实例化一个证书对象,入参需要传入腾讯云账户 secretId,secretKey
$cred = new Credential("secretId", "secretKey");
// 实例化一个 http 选项,可选的,没有特殊需求可以跳过
$httpProfile = new HttpProfile();
// 配置代理
// $httpProfile->setProxy("https://ip:port");
$httpProfile->setEndpoint("vod.tencentcloudapi.com");
// 实例化一个 client 选项,可选的,没有特殊需求可以跳过
$clientProfile = new ClientProfile();
$httpProfile->setReqMethod("GET"); // GET 请求(默认为 post 请求)
$httpProfile->setReqTimeout(30); // 请求超时时间,单位为秒(默认60秒)
$clientProfile->setHttpProfile($httpProfile);
$client = new VodClient($cred, "ap-guangzhou", $clientProfile);
// 实例化一个发起视频处理请求对象,每个接口都会对应一个 request 对象。
$req = new ProcessMediaForDYRequest();
// 构造 API 请求参数
$params = '{
"Action": "ProcessMediaForDY",
"Version": "2018-07-17",
"InputInfo": {
"Type": "COS",
"CosInputInfo": {
"Bucket": "test-1251234567",
"Region": "ap-chongqing",
"Object": "/test/test.mp4"
}
},
"OutputDir": "/test/",
"MediaProcessTask": {
"TranscodeTaskSet": [
{
"Definition": 20
}
]
}
}';
$req->fromJsonString($params);
// 通过 client 对象调用 ProcessMediaForDY 方法发起请求。注意请求方法名与请求对象是对应的
// 返回的 resp 是一个 ProcessMediaForDYResponse 类的实例,与请求对象对应
$resp = $client->ProcessMediaForDY($req);
// 输出json格式的字符串回包
print_r($resp->toJsonString());
// 也可以取出单个值。
// 你可以通过跳转到 response 对象的定义处查看返回字段的定义
print_r($resp->TaskId);
}
catch(TencentCloudSDKException $e) {
echo $e;
}
$cred = new Credential("secretId", "secretKey");
$httpProfile = new HttpProfile();
$httpProfile->setProxy('https://ip:port');
$clientProfile = new ClientProfile();
$clientProfile->setHttpProfile($httpProfile);
$client = new OcrClient($cred, 'ap-beijing', $this->clientProfile);