全部文档
当前文档

暂无内容

如果没有找到您期望的内容,请尝试其他搜索词

文档中心

SDK for PHP 使用指南

最近更新时间:2024-08-15 11:05:42

概述

初始化

创建模板

更新模板

删除模板

查询模板列表

查询模板详情

创建任务

置顶任务

删除任务

查询任务列表

查询任务详情

查询任务META信息

概述

此 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();

查询任务META列表

  • 接口名

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();

同步获取META信息接口

  • 接口名

FetchMetaInfo

  • 调用方式

<?php
require('vendor/autoload.php');
use Ksyun\Service\Kvs;

$response = Kvs::getInstance()->request('FetchMetaInfo', ['json' => ['SrcPath' => '/{bucket}/xxx.flv']]);

echo $response->getBody();

文档导读
纯净模式常规模式

纯净模式

点击可全屏预览文档内容
文档反馈