getProfile() public static method

public static getProfile ( $regionId, $accessKeyId, $accessSecret )
Ejemplo n.º 1
0
 public function __construct($accessKey, $secretKey)
 {
     $iClientProfile = DefaultProfile::getProfile("cn-hangzhou", $accessKey, $secretKey);
     $this->client = new DefaultAcsClient($iClientProfile);
     // 图片检测
     $this->request = new Green\ImageDetectionRequest();
 }
Ejemplo n.º 2
0
 public function generate($sessionName)
 {
     $iClientProfile = \DefaultProfile::getProfile("cn-hangzhou", $this->accessKeyId, $this->accessSecret);
     $client = new \DefaultAcsClient($iClientProfile);
     //进一步限制角色的使用权限
     //默认设置为所有权限
     if (!$this->policy) {
         $this->policy = '
             {
               "Statement": [
                 {
                   "Action": [
                     "oss:*"
                   ],
                   "Effect": "Allow",
                   "Resource": "*"
                 }
               ],
               "Version": "1"
             }
         ';
     }
     $request = new \AssumeRoleRequest();
     $request->setFormat($this->format);
     // RoleSessionName即临时身份的会话名称,用于区分不同的临时身份
     // 您可以使用您的客户的ID作为会话名称
     $request->setRoleSessionName($sessionName);
     $request->setRoleArn($this->defaultRoleArn);
     $request->setPolicy($this->policy);
     $request->setDurationSeconds($this->durationSeconds);
     $response = $client->doAction($request);
     return $response->getBody();
 }
 public function testAddEndpoint()
 {
     $profile = DefaultProfile::getProfile("cn-hangzhou", "accessId", "accessSecret");
     $profile->addEndpoint("cn-hangzhou", "cn-hangzhou", "TestProduct", "testproduct.aliyuncs.com");
     $endpoints = $profile->getEndpoints();
     foreach ($endpoints as $key => $endpoint) {
         if ("cn-hangzhou" == $endpoint->getName()) {
             $regionIds = $endpoint->getRegionIds();
             $this->assertContains("cn-hangzhou", $regionIds);
             $productDomains = $endpoint->getProductDomains();
             $this->assertNotNull($productDomains);
             $productDomain = $this->getProductDomain($productDomains);
             $this->assertNotNull($productDomain);
             $this->assertEquals("TestProduct", $productDomain->getProductName());
             $this->assertEquals("testproduct.aliyuncs.com", $productDomain->getDomainName());
         }
     }
 }
Ejemplo n.º 4
0
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
include_once '../aliyun-php-sdk-core/Config.php';
use Push\Request\V20150827 as Push;
// 设置你的AccessKeyId/AccessSecret/AppKey
$accessKeyId = "";
$accessSecret = "";
$appKey = 123456;
$iClientProfile = DefaultProfile::getProfile("cn-hangzhou", $accessKeyId, $accessSecret);
$client = new DefaultAcsClient($iClientProfile);
// 示例: 调用 PushNoticeToAndroidRequest API
$request = new Push\PushNoticeToAndroidRequest();
$request->setAppKey($appKey);
$request->setTarget("all");
$request->setTargetValue("all");
$request->setTitle("Hello OpenAPI!");
$request->setSummary("PushMessageToAndroid from OpenAPI by PHP SDK!");
$response = $client->getAcsResponse($request);
print_r("\r\n");
print_r($response);
Ejemplo n.º 5
0
 function getProperty($propertyKey)
 {
     $accessKey = "";
     $accessSecret = "";
     $iClientProfile = DefaultProfile::getProfile("cn-hangzhou", "AccessKey", "AccessSecret");
 }
<?php

include_once '../aliyun-php-sdk-core/Config.php';
use Ubsms_inner\Request\V20150623 as ubs;
$iClientProfile = DefaultProfile::getProfile("cn-hangzhou", "123ak", "456secret");
$client = new DefaultAcsClient($iClientProfile);
$request = new ubs\DescribeUserBusinessStatusRequest();
$request->setUid("1250434591322550");
$request->setServiceCode("ecs");
$response = $client->getAcsResponse($request);
print_r("\r\n");
print_r($response);
<?php

include_once '../aliyun-php-sdk-core/Config.php';
use Ubsms_inner\Request\V20150623 as ubs;
$iClientProfile = DefaultProfile::getProfile("cn-hangzhou", "c6FJ7dpnZIU14CRE", "rtHTcpLM56whmWxeLnuCuO0sSGvdp8");
$client = new DefaultAcsClient($iClientProfile);
$request = new ubs\NotifyUserBusinessCommandRequest();
$request->setUid("1250434591322550");
$request->setCmd("ceaseUserResourcesForDebt");
$request->setServiceCode("ecs");
$response = $client->getAcsResponse($request);
print_r("\r\n");
print_r($response);
Ejemplo n.º 8
0
 public function __construct($appkey, $secretkey)
 {
     $this->iClientProfile = \DefaultProfile::getProfile("cn-hangzhou", $appkey, $secretkey);
 }
Ejemplo n.º 9
0
<?php

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
include_once '../aliyun-php-sdk-core/Config.php';
use Ecs\Request\V20140526 as Ecs;
$iClientProfile = DefaultProfile::getProfile("cn-hangzhou", "<your accessKey>", "<your accessSecret>");
$client = new DefaultAcsClient($iClientProfile);
$request = new Ecs\DescribeRegionsRequest();
$request->setMethod("GET");
$response = $client->getAcsResponse($request);
print_r($response);
Ejemplo n.º 10
0
 public function getProperty($propertyKey)
 {
     $accessKey = "";
     $accessSecret = "";
     $iClientProfile = DefaultProfile::getProfile("cn-hangzhou", "5slyhuy4sv30bmppvgew0rps", "NGYL1I7hXC6SgSqkcE5DJdPgJM8=");
 }
 protected function createClient()
 {
     $iClientProfile = \DefaultProfile::getProfile($this->region, $this->appKey, $this->appSecret);
     return new \DefaultAcsClient($iClientProfile);
 }
Ejemplo n.º 12
0
<?php

include_once '../aliyun-php-sdk-core/Config.php';
use Sts\Request\V20150401 as Sts;
// 你需要操作的资源所在的region
$iClientProfile = DefaultProfile::getProfile("cn-hangzhou", "<your accesskeyid>", "<your accesskeysecret>");
$client = new DefaultAcsClient($iClientProfile);
// policy编写参考oss api文档授权访问章节
$policy = "{\n" . "    \"Version\": \"1\",\n" . "    \"Statement\": [\n" . "      {\n" . "        \"Effect\": \"Allow\",\n" . "        \"Action\": [\n" . "             \"oss:GetObject\",\n" . "             \"oss:PutObject\"\n" . "        ],\n" . "        \"Resource\": \"acs:oss:*:*:*/*\"\n" . "      }\n" . "    ]\n" . "  }";
$request = new Sts\GetFederationTokenRequest();
$request->setStsVersion("2015-04-01");
$request->setName("oldratlee");
$request->setPolicy($policy);
$request->setDurationSeconds(3600);
$response = $client->doAction($request);
print_r("\r\n");
print_r($response);
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
include_once '../aliyun-php-sdk-core/Config.php';
use Cs\Request\V20151215 as Cs;
$iClientProfile = DefaultProfile::getProfile("cn-hangzhou", "Your accessKeyId", "Your accessKeySecret");
$client = new DefaultAcsClient($iClientProfile);
//createCluster($client);
//scaleCluster($client,"c00a43b26e71a4c05ac0b592b7bb32830");
//deleteCluster($client,"cacdffd35104b46c79280d86bc4e3a745");
//describeApiVersion($client);
//describeClusters($client);
//describeClusterInfo($client,"c550e0c06c16042c39c9335c60563fcd5");
//describeClusterCerts($client,"c550e0c06c16042c39c9335c60563fcd5");
function createCluster($client)
{
    $params = array("password" => "Just12345", "instance_type" => "ecs.t1.small", "name" => "my-php-cluster-" . time(), "size" => 1, "network_mode" => "classic", "data_disk_category" => "cloud", "data_disk_size" => 40, "ecs_image_id" => "m-23lgldfxg");
    $request = new Cs\CreateClusterRequest();
    $request->setMethod("POST");
    $request->setContent(json_encode($params));
    $response = $client->doAction($request);
<?php

include_once '../aliyun-php-sdk-core/Config.php';
use Ubsms_inner\Request\V20150623 as ubs;
$iClientProfile = DefaultProfile::getProfile("cn-hangzhou", "ks7iw5e4zhFp7HzZ", "6IQ2c6i4SepX1qY1KGaufypKN0Xld7");
$client = new DefaultAcsClient($iClientProfile);
$request = new ubs\SetUserSecurityStatusRequest();
$request->setUid("1837537388585180");
$request->setStatusKey1("prohibitedByRiskControl");
$request->setStatusValue1("false");
$response = $client->getAcsResponse($request);
print_r("\r\n");
print_r($response);