← Installation | Client(中文) | Request →
You may create multiple different clients simultaneously. Each client can have its own configuration, and each request can be sent by specified client. Use the Default Client if it is not specified. The client can be created by auto-loading of the configuration files, or created and managed manually. Different types of clients require different Credential
,and different Signature
algorithms that are selected. You may also customize the client: that is, pass in custom credentials and signatures.
Setup AccessKey through User Information Management, they have full authority over the account, please keep them safe. Sometimes for security reasons, you cannot hand over a primary account AccessKey with full access to the developer of a project. You may create a sub-account RAM Sub-account , grant its authorization,and use the AccessKey of RAM Sub-account to make API calls.
Sample Code: Create a client with a certification type AccessKey, and set it to the Default Client,that is, a client named as
default
.
<?php
use AlibabaCloud\Client\AlibabaCloud;
AlibabaCloud::accessKeyClient('accessKeyId', 'accessKeySecret')->asDefaultClient();
AlibabaCloud::accessKeyClient('accessKeyId', 'accessKeySecret')->name('default');
Create a temporary security client by applying Temporary Security Credentials (TSC) through the Security Token Service (STS).
<?php
use AlibabaCloud\Client\AlibabaCloud;
AlibabaCloud::stsClient('accessKeyId', 'accessKeySecret', 'securityToken')->name('sts');
By specifying RAM Role, the client will be able to automatically request maintenance of STS Token before making a request, and be automatically converted to a time-limited STS client. You may also apply for Token maintenance by yourself before creating STS Client
.
Sample Code: Create a client with a certification type RamRoleArn, name it as
ramRoleArnClient
.
<?php
use AlibabaCloud\Client\AlibabaCloud;
AlibabaCloud::ramRoleArnClient('accessKeyId', 'accessKeySecret', 'roleArn', 'roleSessionName')
->name('ramRoleArnClient');
By specifying the role name, the client will be able to automatically request maintenance of STS Token before making a request, and be automatically converted to a time-limited STS client. You may also apply for Token maintenance by yourself before creating STS Client
.
Sample Code: Create a client with a certification type EcsRamRole, name it as
ecsRamRoleClient
.
<?php
use AlibabaCloud\Client\AlibabaCloud;
AlibabaCloud::ecsRamRoleClient('roleName')->name('ecsRamRoleClient');
If clients with this certification type are required by the Cloud Call Centre (CCC), please apply for Bearer Token maintenance by yourself.
Sample Code: Create a client with a certification type Bearer Token, name it as
bearerTokenClient
.
<?php
use AlibabaCloud\Client\AlibabaCloud;
AlibabaCloud::bearerTokenClient('token')->name('bearerTokenClient');
By specifying the public key ID and the private key file, the client will be able to automatically request maintenance of the AccessKey before sending the request, and be automatically converted to a time-limited AccessKey client. Only Japan station is supported.
Sample Code: Create a client with a certification type RsaKeyPair, name it as
rsaKeyPairClient
.
<?php
use AlibabaCloud\Client\AlibabaCloud;
AlibabaCloud::rsaKeyPairClient('publicKeyId', '/your/privateKey.pem')->name('rsaKeyPairClient');