config['secret_id'], $this->config['secret_key']); // 实例化一个http选项,可选的,没有特殊需求可以跳过 $httpProfile = new HttpProfile(); $httpProfile->setEndpoint("sts.tencentcloudapi.com"); // 实例化一个client选项,可选的,没有特殊需求可以跳过 $clientProfile = new ClientProfile(); $clientProfile->setHttpProfile($httpProfile); // 实例化要请求产品的client对象,clientProfile是可选的 $client = new StsClient($cred, $this->config['region'], $clientProfile); // 实例化一个请求对象,每个接口都会对应一个request对象 $req = new GetFederationTokenRequest(); $params = [ "Name" => $name, "Policy" => urlencode(json_encode($policy)) ]; $req->fromJsonString(json_encode($params)); // 返回的resp是一个GetFederationTokenResponse的实例,与请求对象对应 $resp = $client->GetFederationToken($req); // 输出json格式的字符串回包 $resp = $resp->toJsonString(); $result = json_decode($resp, true); // 记录日志 $uid = defined('UID') ? UID : ''; platformLog([ "Name" => $name, "Policy" => $policy ], $result, 'tencent_sts_get_federation_token_uid_' . $uid); return $result; } catch (TencentCloudSDKException $e) { echo $e; } } }