setEndpoint("cn-hangzhou"); // EndpointProvider::setEndpoints($params['storage_aliyun_endpoint']); $client = new DefaultAcsClient($iClientProfile); $request = new AssumeRoleRequest(); $request->setRoleSessionName("bigVideo"); $request->setRoleArn($roleArn); // $request->setPolicy($policy); $request->setDurationSeconds($tokenExpire); $response = $client->doAction($request); $rows = array(); $body = $response->getBody(); $content = json_decode($body, true); $rows['status'] = $response->getStatus(); if ($rows['status'] != 200) throw new Exception($content['Message']); $rows['AccessKeyId'] = $content['Credentials']['AccessKeyId']; $rows['AccessKeySecret'] = $content['Credentials']['AccessKeySecret']; $rows['Expiration'] = $content['Credentials']['Expiration']; $rows['SecurityToken'] = $content['Credentials']['SecurityToken']; return $rows; } catch (\Exception $e) { throw new Exception($e->getMessage()); } } public function setEndpoint($endpoint) { $regionIds = array("cn-hangzhou","cn-beijing","cn-qingdao","cn-hongkong","cn-shanghai","us-west-1","cn-shenzhen","ap-southeast-1"); $productDomains =array( new ProductDomain("Ecs", "ecs.aliyuncs.com"), new ProductDomain("Rds", "rds.aliyuncs.com"), new ProductDomain("BatchCompute", "batchCompute.aliyuncs.com"), new ProductDomain("Bss", "bss.aliyuncs.com"), new ProductDomain("Oms", "oms.aliyuncs.com"), new ProductDomain("Slb", "slb.aliyuncs.com"), new ProductDomain("Oss", "oss-cn-hangzhou.aliyuncs.com"), new ProductDomain("OssAdmin", "oss-admin.aliyuncs.com"), new ProductDomain("Sts", "sts.aliyuncs.com"), new ProductDomain("Yundun", "yundun-cn-hangzhou.aliyuncs.com"), new ProductDomain("Risk", "risk-cn-hangzhou.aliyuncs.com"), new ProductDomain("Drds", "drds.aliyuncs.com"), new ProductDomain("M-kvstore", "m-kvstore.aliyuncs.com"), new ProductDomain("Ram", "ram.aliyuncs.com"), new ProductDomain("Cms", "metrics.aliyuncs.com"), new ProductDomain("Crm", "crm-cn-hangzhou.aliyuncs.com"), new ProductDomain("Ocs", "pop-ocs.aliyuncs.com"), new ProductDomain("Ots", "ots-pop.aliyuncs.com"), new ProductDomain("Dqs", "dqs.aliyuncs.com"), new ProductDomain("Location", "location.aliyuncs.com"), new ProductDomain("Ubsms", "ubsms.aliyuncs.com"), new ProductDomain("Ubsms-inner", "ubsms-inner.aliyuncs.com") ); $endpoint = new Endpoint($endpoint, $regionIds, $productDomains); $endpoints = array($endpoint); EndpointProvider::setEndpoints($endpoints); } }