阅读223 返回首页    go 人物


PHP-SDK__点播SDK_SDK手册_视频点播-阿里云

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/EndpointConfig.php,在最后增加北京区域(其他区域类似):

    1. $endpoints[] = new Endpoint(
    2. "mts-cn-beijing",
    3. array("mts-cn-beijing"),
    4. array(new ProductDomain("Mts", "mts.cn-beijing.aliyuncs.com")));
    5. EndpointProvider::setEndpoints($endpoints);
    • API调用示例

      下面以SearchMediaWorkflowAPI调用为例。其中最重要的是设置$request的RegionId属性,其他API调用类似。

      1. include_once 'aliyun-php-sdk-core/Config.php';
      2. use MtsRequestV20140618 as Mts;
      1. function search_media_workflow($client, $regionId)
      2. {
      3. $request = new MtsSearchMediaWorkflowRequest();
      4. $request->setAcceptFormat('JSON');
      5. $request->setRegionId($regionId); //重要
      6. $response = $client->getAcsResponse($request);
      7. return $response;
      8. }
    • 杭州区域调用示例

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

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

最后更新:2016-11-23 18:24:22

  上一篇:go JAVA-SDK__点播SDK_SDK手册_视频点播-阿里云
  下一篇:go PYTHON-SDK__点播SDK_SDK手册_视频点播-阿里云