1, live cloud does not have a separate SDK, live part of the SDK is directly encapsulated in the relevant SDK of CDN inside
2, for the SDK, no demo.
3, for the SDK, there is no relevant documentation description.
4, for the SDK instructions, the site above the description and source code inside the description is completely inconsistent.
5, for the SDK does not encapsulate those commonly used access, the need for user combination to invoke the SDK to assemble, in short, this is too abstract, look at someone else seven cow API, hey, don't say anything more
6, the provision of the SDK path chaos of a tread confused, want to directly use no way, have a variety of adjustments.
7, for the SDK based on a higher version of PHP registration, not to take care of some low version of the user.
For the above several reasons, stepped on a part of the pit, reference to other cloud live provided by the common interface to organize.
First, let's analyze the PHP SDK provided by Aliyun. The Aliyun SDK directory structure is as follows:
Aliyun-php-sdk-core: As a PHP SDK reference core package, as long as the use of Aliyun products PHP SDK, this folder all the stuff is the foundation.
ALIYUN-PHP-SDK-CDN: This package is the Aliyun CDN product PHP SDK, but the current live inside of the SDK in this, may be because of live products and CDN products more closely! (PS: In the opening of live products, CDN product opening is the prerequisite)
The following figure is the entire package from the Aliyun PHP SDK, which contains the PHP SDK for all products Aliyun.
Next down, let's look at how the configuration, this step is very critical, Aliyun's official website above content and SDK demo, there are three versions. (This is the root of pain, haha)
1, the entire PHP SDK package placed in the project directory.
2. Configure Aliyun-php-sdk-core
There's a config.php file underneath the Aliyun-php-sdk-core.
The code is as follows |
Copy Code |
Include_once ' autoloader/autoloader.php '; Include_once ' regions/endpointconfig.php '; Config SDK auto load path. Autoloader::addautoloadpath ("Aliyun-php-sdk-cdn"); Autoloader::addautoloadpath ("Aliyun-php-sdk-batchcompute"); Autoloader::addautoloadpath ("aliyun-php-sdk-sts"); Autoloader::addautoloadpath ("Aliyun-php-sdk-push"); Autoloader::addautoloadpath ("Aliyun-php-sdk-ram"); Autoloader::addautoloadpath ("aliyun-php-sdk-ubsms"); Autoloader::addautoloadpath ("Aliyun-php-sdk-ubsms-inner"); Autoloader::addautoloadpath ("Aliyun-php-sdk-green"); Autoloader::addautoloadpath ("ALIYUN-PHP-SDK-DM"); Autoloader::addautoloadpath ("Aliyun-php-sdk-iot"); Config HTTP proxy Define (' Enable_http_proxy ', FALSE); Define (' Http_proxy_ip ', ' 127.0.0.1 '); Define (' Http_proxy_port ', ' 8888 '); Autoloader::addautoloadpath ("Aliyun-php-sdk-cdn"); |
This sentence as the core, means to automatically load all the PHP files under the Aliyun-php-sdk-cdn folder. ALIYUN-PHP-SDK-CDN is the SDK for live services, and if you want to use the other features of Aliyun, you need to refer to other related folders.
3, call live related PHP SDK
The code is as follows |
Copy Code |
Reference config.php file, the path is defined according to the actual situation Include_once (' Aliyunopenapi '. Directory_separator. ' Aliyun-php-sdk-core '. Directory_separator. ' config.php '); $accessKeyId, $accessSecret as Aliyun key $iClientProfile = Defaultprofile::getprofile ("Cn-hangzhou", $accessKeyId, $accessSecret); $client = new Defaultacsclient ($iClientProfile);
|
To initialize the specific operation of the live broadcast, Describeliverecordconfigrequest is to get the live cloud below, all the created app
The code is as follows |
Copy Code |
$request = new Cdn\request\v20141111\describeliverecordconfigrequest (); $request->setdomainname (' live.ezoon.cn '); $request->setappname ($appname); $request->setossendpoint (' oss-cn-hangzhou.aliyuncs.com '); $request->setossbucket (' Liveplaybucket '); $request->setossobjectprefix (' record/'. $appname. /{streamname}/{unixtimestamp}_{sequence} ');
Making requests for Aliyun $response = $this->client->getacsresponse ($request); Print_r ("\ r \ n"); Print_r ($response); |
4, to see the results returned by the data, the value returned is an object, which
The code is as follows |
Copy Code |
StdClass Object ( [Liveapprecordlist] => stdClass Object ( [Liveapprecord] => Array ( [0] => StdClass Object ( [Createtime] => 2016-07-27t09:48:23z [DomainName] => live.xxx.cn [Ossendpoint] => oss-cn-hangzhou.aliyuncs.com [AppName] => Asfdsadfsadfafds [Ossobjectprefix] => record/asfdsadfsadfafds/{streamname}/{unixtimestamp}_{sequence} [Ossbucket] => Liveplaybucket ) [1] => StdClass Object ( [Createtime] => 2016-07-26t06:46:28z [DomainName] => live.xxx.cn [Ossendpoint] => oss-cn-hangzhou.aliyuncs.com [AppName] => live1 [Ossobjectprefix] => record/live1/{streamname}/{unixtimestamp}_{sequence} [Ossbucket] => Liveplaybucket ) [2] => StdClass Object ( [Createtime] => 2016-07-27t09:37:54z [DomainName] => live.xxx.cn [Ossendpoint] => oss-cn-hangzhou.aliyuncs.com [AppName] => live1213123213 [Ossobjectprefix] => record/live1213123213/{streamname}/{unixtimestamp}_{sequence} [Ossbucket] => Liveplaybucket ) [3] => StdClass Object ( [Createtime] => 2016-07-26t02:55:09z [DomainName] => live.xxx.cn [Ossendpoint] => oss-cn-hangzhou.aliyuncs.com [AppName] => Liveezoon [Ossobjectprefix] => record/liveezoon/{streamname}/{unixtimestamp}_{sequence} [Ossbucket] => Liveplaybucket ) [4] => StdClass Object ( [Createtime] => 2016-07-26t02:55:26z [DomainName] => live.xxx.cn [Ossendpoint] => oss-cn-hangzhou.aliyuncs.com [AppName] => livetest [Ossobjectprefix] => record/livetest/{streamname}/{unixtimestamp}_{sequence} [Ossbucket] => Liveplaybucket ) ) ) [RequestID] => 392b879d-2a09-47b3-85cf-627f7bcd3ac1 ) |