This topic describes how to initialize ApsaraVideo VOD SDK for PHP by using an AccessKey pair or a Security Token Service (STS) token.
Prerequisites
An Alibaba Cloud account is created. To create an Alibaba Cloud account, visit the account registration page. Real-name verificationis completed. ApsaraVideo VOD is activated.
An AccessKey pair is created to call ApsaraVideo VOD operations. You can create the AccessKey pair of your Alibaba Cloud account in the User Management console. Alternatively, you can create a RAM user in the RAM console and grant the RAM user the permissions on ApsaraVideo VOD. For more information, see Create a RAM user and perform authorization.
Initialize the SDK
Determine the region where you want to call ApsaraVideo VOD operations. For more information about the supported regions, see Access regions and IDs. For example, if you want to call the operations in the China (Shanghai) region, use cn-shanghai
.
Use the AccessKey pair to initialize the SDK. Example:
require_once './aliyun-php-sdk/aliyun-php-sdk-core/Config.php'; // Assume that your source code file is stored in the same directory as aliyun-php-sdk. use vod\Request\V20170321 as vod; function initVodClient($accessKeyId, $accessKeySecret) { $regionId = 'cn-shanghai'; // The region where you want to call ApsaraVideo VOD operations. $profile = DefaultProfile::getProfile($regionId, $accessKeyId, $accessKeySecret); return new DefaultAcsClient($profile); }
Use an STS token to initialize the SDK. Example:
require_once './aliyun-php-sdk/aliyun-php-sdk-core/Config.php'; // Assume that your source code file is stored in the same directory as aliyun-php-sdk. use vod\Request\V20170321 as vod; function initVodClient($accessKeyId, $accessKeySecret, $securityToken) { $regionId = 'cn-shanghai'; // The region where you want to call ApsaraVideo VOD operations. $profile = DefaultProfile::getProfile($regionId, $accessKeyId, $accessKeySecret, $securityToken); return new DefaultAcsClient($profile); }
If you fail to call ApsaraVideo VOD operations in other regions, update the aliyun-php-sdk-core SDK to version 1.3.8 or later, and the aliyun-php-sdk-vod SDK to version 2.15.1 or later.