PHP-SDK

更新时间:2017-01-11 16:38:14

SDK-PHP

  • 环境要求

    PHP 5.3+

  • 安装

    • 从Github上下载PHP SDK的源代码

    • 拷贝aliyun-php-sdk-core文件夹和aliyun-php-sdk-mts的文件夹到您的项目中,并且放置在同一个目录下。

    • 编辑aliyun-php-sdk-core/Config.php

      找到“//config sdk auto load path.”,在这行下面添加:

      Autoloader::addAutoloadPath("aliyun-php-sdk-mts");

  • 多区域支持

    编辑aliyun-php-sdk-core/Regions/endpoints.xml文件,在最后一行(</Endpoints>)之前添加北京区域(其他区域类似):

    ```

    mts-cn-beijing Mts mts.cn-beijing.aliyuncs.com

  * API调用示例

    下面以`SearchMediaWorkflow`API调用为例。其中最重要的是设置$request的RegionId属性,其他API调用类似。
  include_once 'aliyun-php-sdk-core/Config.php';
  use Mts\Request\V20140618 as Mts;
```

```
  function search_media_workflow($client, $regionId)
  {
      $request = new Mts\SearchMediaWorkflowRequest();
      $request->setAcceptFormat('JSON');
      $request->setRegionId($regionId); //重要
      $response = $client->getAcsResponse($request);
      return $response;
  }
```
  • 杭州区域调用示例

      include_once 'aliyun-php-sdk-core/Config.php';
    
      $profile = DefaultProfile::getProfile('cn-hangzhou',
                                       $access_key_id,
                                       $access_key_secret);
      $client = new DefaultAcsClient($profile);
      search_media_workflow($client, 'cn-hangzhou');
    
  • 北京区域调用示例

      include_once 'aliyun-php-sdk-core/Config.php';
    
      $profile = DefaultProfile::getProfile('mts-cn-beijing',
                                       $access_key_id,
                                       $access_key_secret);
      $client = new DefaultAcsClient($profile);
      search_media_workflow($client, 'mts-cn-beijing');
    

results matching ""

    No results matching ""