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.
Inheritance: implements IAcsClient
Example #1
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();
 }
Example #2
0
 public function checkTextWord($text)
 {
     $client = new \DefaultAcsClient($this->iClientProfile);
     $request = new TextWordCorrectRequest();
     $request->setText($text);
     $response = $client->getAcsResponse($request);
     return $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 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);
Example #4
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);