全部产品
媒体转码

查询媒体-使用OSS文件地址

更新时间:2017-09-20 10:46:48   分享:   

用户在不知道媒体ID的情况下(直播走工作流转点播),可以通过媒体的输入地址进行媒体信息的查询,接口为 QueryMediaListByURL

  1. <?php
  2. include_once 'aliyun-php-sdk-core/Config.php';
  3. use Mts\Request\V20140618 as Mts;
  4. date_default_timezone_set('PRC');
  5. class QueryMediaListByURLDemo {
  6. private $client;
  7. private $region = '<region>';
  8. private $accessKeyId = '<accessKeyId>';
  9. private $accessKeySecret = '<accessKeySecret>';
  10. function __construct()
  11. {
  12. $profile = DefaultProfile::getProfile($this->region, $this->accessKeyId, $this->accessKeySecret);
  13. $this->client = new DefaultAcsClient($profile);
  14. }
  15. function queryMediaListByUrl()
  16. {
  17. $request = new Mts\QueryMediaListByURLRequest();
  18. $ossDomain = 'http://<input-bucket>.<region>.aliyuncs.com/';
  19. #ossObject需要RFC3986编码
  20. $ossObject = $this->encodeByRFC3986('test/笑傲江湖.mp4');
  21. $request->setFileURLs($ossDomain.$ossObject);
  22. $response = $this->client->getAcsResponse($request);
  23. echo json_encode($response);
  24. }
  25. function encodeByRFC3986($arg_1)
  26. {
  27. $encodeOssObject="";
  28. $arraylist = explode("/", $arg_1);
  29. for($i = 0; $i < count($arraylist); $i++)
  30. {
  31. $tmp = rawurlencode($arraylist[$i]);
  32. $encodeOssObject = $encodeOssObject.$tmp;
  33. if ($i !== count($arraylist) -1) {
  34. $encodeOssObject = $encodeOssObject."/";
  35. }
  36. }
  37. return $encodeOssObject;
  38. }
  39. }
  40. $demo = new QueryMediaListByURLDemo();
  41. $demo->queryMediaListByUrl();
  42. ?>
本文导读目录
本文导读目录
以上内容是否对您有帮助?