This topic describes how to use the server SDK for PHP provided by ApsaraVideo Live.

Prerequisites

PHP 5.5.0 or later is installed.

Procedure

  1. Log on to the server.
  2. Install ApsaraVideo Live SDK.

    composer require alibabacloud/live

    Note If the installation fails due to network issues, you can install Alibaba Cloud Composer Mirror. For more information, see Alibaba Cloud Composer Mirror.
  3. Initiate the client.
    <?php
    
    use AlibabaCloud\Client\AlibabaCloud;
    
    AlibabaCloud::accessKeyClient('accessKeyId', 'accessKeySecret')->asDefaultClient();
  4. Call an operation by using the Remote Procedure Call (RPC) style. In this example, the DescribeCdnService operation is called.
    <?php
    
    use AlibabaCloud\Client\AlibabaCloud;
    use AlibabaCloud\Client\Exception\ClientException;
    use AlibabaCloud\Client\Exception\ServerException;
    
    try {
        $result = AlibabaCloud::rpc()
                              ->product('live')
                              ->version('2020-05-28')
                              ->action('DescribeCdnService')
                              ->method('POST')
                              ->request();
    
        print_r($result->toArray());
    
    } catch (ClientException $exception) {
        print_r($exception->getErrorMessage());
    } catch (ServerException $exception) {
        print_r($exception->getErrorMessage());
    }

    For more information, see API overview.