阿里云phpsdk的使用方法

首先安装composer包:composer require o0x00/aliyunsdk

安装完之后,参考示例:

<?php
require_once "./vendor/autoload.php";

use live\Request\V20161101\DescribeLiveRecordConfigRequest;

/**
 * init aliyun core
 *
 * @author 剑心 <0x00gc@gmail.com>
 * @DateTime  2018-12-01
 * @return    object 	DefaultAcsClient
 */
function initClict()
{
	//config http proxy
	define('ENABLE_HTTP_PROXY', false);
	define('HTTP_PROXY_IP', '127.0.0.1');
	define('HTTP_PROXY_PORT', '8888');

	// read config : [$regionId, $accessKeyId, $accessSecret]
	$iClientProfile = DefaultProfile::getProfile("cn-shanghai", "******", "******************");
	return new DefaultAcsClient($iClientProfile);
}

// eg: Query live config
// doc: https://help.aliyun.com/document_detail/35420.html

$client = initClict();
$data = [];
$data['AppName'] = '****';
$data['DomainName'] = '****.*****.com.cn';
try {
    $DescribeLiveRecordConfigRequest = new DescribeLiveRecordConfigRequest();
    $DescribeLiveRecordConfigRequest->setDomainName($data['DomainName']);
    $response = $client->getAcsResponse($DescribeLiveRecordConfigRequest);
} catch (\Throwable $th) {
    print_r($th);
    exit("error");
}

foreach($response->LiveAppRecordList->LiveAppRecord as $k=>$v)
{
	echo '<pre>';
    print_r($v);
	echo '</pre>';
}

/*

stdClass Object
(
    [StreamName] => *
    [CreateTime] => 2017-10-30T11:05:52Z
    [DomainName] => *****.*****.com.cn
    [RecordFormatList] => stdClass Object
        (
            [RecordFormat] => Array
                (
                    [0] => stdClass Object
                        (
                            [Format] => mp4
                            [CycleDuration] => 3300
                            [OssObjectPrefix] => record/tlive/{Date}/{StreamName}/{StartTime}_{EndTime}
                        )

                )

        )

    [OssEndpoint] => oss-cn-shanghai.aliyuncs.com
    [AppName] => tlive
    [OssBucket] => ****-****-****
    [OnDemond] => 0
)

 */

有不明白的地方可以给我发送邮件(0x00gc@gmail.com),也可直接评论本文。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值