最近更新时间:2024-08-15 11:05:42
此 SDK 适用于PHP 5.5 及以上版本。基于离线转码 API 构建。使用此 SDK 构建您的网络应用程序,能让您以非常便捷地方式调用金山云的离线转码服务。
ak/sk配置
在金山云控制台获取到ak/sk后创建以下文件:
mkdir ~/.ksyun && vi ~/.ksyun/config
config文件内容
{
"ak":"********************",
"sk":"****************************************"
}
composer安装
mkdir test && cd test
composer require kscsdk/ksyun_sdk
如果需要使用最新版本,安装完之后,修改composer.json为
{
"require": {
"kscsdk/ksyun_sdk": "dev-master"
}
}
然后再执行更新操作
composer update
调试demo
cp vendor/kscsdk/ksyun_sdk/examples/demo_Kvs.php .
php demo_Kvs.php GetPresetList
调用示例
<?php
require('vendor/autoload.php');
use Ksyun\Service\Kvs;
$response = Kvs::getInstance()->request('GetPresetList');
echo $response->getBody();
接口名
Preset
调用方式
<?php
require('vendor/autoload.php');
use Ksyun\Service\Kvs;
// 拼凑模板数组
$preset_data = array(
'Preset' => 'xxx',
'Description' => 'xxx',
'PresetType' => 'xxx',
'Param' => array(
'f' => 'xxx',
'VIDEO' => array(
'vr' => '13',
'vb' => '780000',
'vcodec' => 'h264',
'width' => 500,
'height' => 600
),
'AUDIO' => array(
'ar' => '44100',
'ab' => '64k',
'acodec' => 'aac',
'an' => 0
)
)
);
$response = Kvs::getInstance()->request('Preset', ['json' => $preset_data]);
echo $response->getBody();
接口名
UpdatePreset
调用方式
<?php
require('vendor/autoload.php');
use Ksyun\Service\Kvs;
// 拼凑模板数组
$preset_data = array(
'Preset' => 'xxx',
'Description' => 'xxx',
'PresetType' => 'xxx',
'Param' => array(
'f' => 'xxx',
'VIDEO' => array(
'vr' => '13',
'vb' => '780000',
'vcodec' => 'h264',
'width' => 500,
'height' => 600
),
'AUDIO' => array(
'ar' => '44100',
'ab' => '64k',
'acodec' => 'aac',
'an' => 0
)
)
);
$response = Kvs::getInstance()->request('UpdatePreset', ['json' => $preset_data]);
echo $response->getBody();
接口名
DelPreset
调用方式
<?php
require('vendor/autoload.php');
use Ksyun\Service\Kvs;
$response = Kvs::getInstance()->request('DelPreset', ['query' => ['Preset' => 'xxx']]);
echo $response->getBody();
接口名
GetPresetList
调用方式
<?php
require('vendor/autoload.php');
use Ksyun\Service\Kvs;
$response = Kvs::getInstance()->request('GetPresetList', ['query' => ['PresetType' => 'xxx', 'Presets' => 'xxx']]);
echo $response->getBody();
接口名
GetPresetDetail
调用方式
<?php
require('vendor/autoload.php');
use Ksyun\Service\Kvs;
$response = Kvs::getInstance()->request('GetPresetDetail', ['query' => ['Preset' => 'xxx']]);
echo $response->getBody();
接口名
CreateTask
调用方式
<?php
require('vendor/autoload.php');
use Ksyun\Service\Kvs;
// 拼凑参数数组
$task_data = array(
'Preset' => 'xxx',
'srcInfo' => array(
array(
'path' => 'xxx',
'index' => 0,
'type' => 'video',
)
),
'dstBucket' => 'xxx',
'dstDir' => '',
'dstObjectKey' => 'xxx',
'dstAcl' => 'public-read',
'isTop' => 0,
'cbUrl' => '',
'cbMethod' => '',
'extParam' => ''
);
$response = Kvs::getInstance()->request('CreateTask', ['json' => $task_data]);
echo $response->getBody();
接口名
TopTaskByTaskID
调用方式
<?php
require('vendor/autoload.php');
use Ksyun\Service\Kvs;
$response = Kvs::getInstance()->request('TopTaskByTaskID', ['query' => ['TaskID' => 'xxx']]);
echo $response->getBody();
接口名
DelTaskByTaskID
调用方式
<?php
require('vendor/autoload.php');
use Ksyun\Service\Kvs;
$response = Kvs::getInstance()->request('DelTaskByTaskID', ['query' => ['TaskID' => 'xxx']]);
echo $response->getBody();
接口名
GetTaskList
调用方式
<?php
require('vendor/autoload.php');
use Ksyun\Service\Kvs;
$response = $response = Kvs::getInstance()->request('GetTaskList', ['query' => ['StartDate' => '20160815', 'EndDate' => '20160816', 'Marker' => 0, 'Limit' => 2]]);
echo $response->getBody();
接口名
GetTaskByTaskID
调用方式
<?php
require('vendor/autoload.php');
use Ksyun\Service\Kvs;
$response = Kvs::getInstance()->request('GetTaskByTaskID', ['query' => ['TaskID' => 'xxx']]);
echo $response->getBody();
接口名
GetTaskMetaInfo
调用方式
<?php
require('vendor/autoload.php');
use Ksyun\Service\Kvs;
// 通过任务ID查询
$response = Kvs::getInstance()->request('GetTaskMetaInfo', ['query' => ['TaskID' => 'xxx']]);
// 查询列表
$response = Kvs::getInstance()->request('GetTaskMetaInfo', ['query' => ['StartDate' => '20160929', 'EndDate' => '20160930', 'Marker' => 0, 'Limit' => 1]]);
echo $response->getBody();
接口名
FetchMetaInfo
调用方式
<?php
require('vendor/autoload.php');
use Ksyun\Service\Kvs;
$response = Kvs::getInstance()->request('FetchMetaInfo', ['json' => ['SrcPath' => '/{bucket}/xxx.flv']]);
echo $response->getBody();
纯净模式