|
@@ -8,6 +8,9 @@ use Darabonba\OpenApi\Models\Config;
|
|
|
use AlibabaCloud\SDK\Sts\V20150401\Models\AssumeRoleRequest;
|
|
|
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
|
|
|
use AlibabaCloud\SDK\Vod\V20170321\Models\GetVideoPlayAuthRequest;
|
|
|
+use AlibabaCloud\Client\AlibabaCloud;
|
|
|
+use AlibabaCloud\Client\Exception\ClientException;
|
|
|
+use AlibabaCloud\Client\Exception\ServerException;
|
|
|
require_once '../vendor/aliyunmail/aliyun-php-sdk-core/Config.php'; // 假定您的源码文件和aliyun-php-sdk处于同一目录
|
|
|
$path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
|
|
|
if (file_exists($path)) require_once $path;
|
|
@@ -85,7 +88,35 @@ class OssManage extends Base
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+ public function index(){
|
|
|
+ //构建一个阿里云客户端,用于发起请求。
|
|
|
+ //设置调用者(RAM用户或RAM角色)的AccessKey ID和AccessKey Secret。
|
|
|
+ AlibabaCloud::accessKeyClient($this->access_key, $this->access_secret)->regionId('cn-hangzhou')->asDefaultClient();
|
|
|
+ //设置参数,发起请求。
|
|
|
+ try {
|
|
|
+ $result = AlibabaCloud::rpc()
|
|
|
+ ->product('Sts')
|
|
|
+ ->scheme('https')
|
|
|
+ ->version('2015-04-01')
|
|
|
+ ->action('AssumeRole')
|
|
|
+ ->method('POST')
|
|
|
+ ->host('sts.aliyuncs.com')
|
|
|
+ ->options([
|
|
|
+ 'query' => [
|
|
|
+ 'RegionId' => "cn-hangzhou",
|
|
|
+ 'RoleArn' => $this->role_arn,
|
|
|
+ 'RoleSessionName' => $this->role_session_name
|
|
|
+ ],
|
|
|
+ ])
|
|
|
+ ->request();
|
|
|
+ $ret = $result->toArray();
|
|
|
+ $this->success('请求成功',$ret);
|
|
|
+ } catch (ClientException $e) {
|
|
|
+ $this->error($e->getErrorMessage() . PHP_EOL);
|
|
|
+ } catch (ServerException $e) {
|
|
|
+ $this->error($e->getErrorMessage() . PHP_EOL);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|