PHP code example of jimchen / aliyun-php-sdk-sts

1. Go to this page and download the library: Download jimchen/aliyun-php-sdk-sts library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jimchen / aliyun-php-sdk-sts example snippets


use JimChen\AliyunSts\Client;
$client = new Client(
        $accessKeyId,
        $accessKeySecret,
        $regionId,
        $clientName,
        $debug,
        $connectionTimeout,
        $timeout,
        $cert,
        $options
);

$result = $client->assumeRole()
    ->client($clientName)
    ->withRoleArn($roleArn)
    ->withRoleSessionName($roleSessionName)
    ->withDurationSeconds($durationSeconds)
    ->request();

$result->isSuccess();

$result = app('aliyun.sts')->assumeRole()
    ->client($clientName)
    ->withRoleArn($roleArn)
    ->withRoleSessionName($roleSessionName)
    ->withDurationSeconds($durationSeconds)
    ->request();

$result->isSuccess();
shell
$ composer 
bash
$ php artisan vendor:publish --provider='JimChen\AliyunSts\LaravelProvider'