PHP code example of codemonkeyluffy / aliyun-sts

1. Go to this page and download the library: Download codemonkeyluffy/aliyun-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/ */

    

codemonkeyluffy / aliyun-sts example snippets




return [

    /*STS配置*/
    'sts' => [
        'AccessKeyID' => '****密码不给看****',
        'AccessKeySecret' => '****密码不给看****',
        'regionId' => 'cn-beijing',
        'endpoint' => 'sts.cn-beijing.aliyuncs.com',
        'roleArn' => 'acs:ram::1******38:role/aliyun*******rkfdale',  // 角色资源描述符,在RAM的控制台的资源详情页上可以获取
        'timeout' => '3600',  // 令牌过期时间
        'client_name' => 'client_name',  // setRoleSessionName可以不改
        // 在扮演角色(AssumeRole)时,可以附加一个授权策略,进一步限制角色的权限;
        // 详情请参考《RAM使用指南》
        // 这代表所有权限
        'policy' => [
            'Statement' => [
                [
                    'Action' => ["oss:*"],
                    'Effect' => 'Allow',
                    'Resource' => ["acs:oss:*:*:*"],
                ]
            ]
        ]
    ]
];



use CodeMonkeyLuffy\AliSTS\Services\STSService;
 
        try {
            $config = // 获取播放权限参数
            print_r($result);
            return $result;
        } catch (\Exception $e) {
            $err = "Error : 错误:" . $e->getMessage();
            echo $err . PHP_EOL;
        }