閱讀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手冊_視頻點播-阿裏雲