Vod.Class.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * 腾讯云-点播
  4. * Created by PhpStorm.
  5. * User: phperstar
  6. * Date: 2019/10/26
  7. * Time: 6:07 PM
  8. */
  9. namespace Util\TencentCloud;
  10. use Mall\Framework\Core\ResultWrapper;
  11. use Mall\Framework\Core\ErrorCode;
  12. class Vod
  13. {
  14. /**
  15. * 腾讯云安全凭证
  16. * @var string $secret_id
  17. */
  18. private $secret_id;
  19. /**
  20. * 腾讯云安全凭证
  21. * @var string $secret_key
  22. */
  23. private $secret_key;
  24. public function __construct($secret_id='', $secret_key='')
  25. {
  26. $this->secret_id = $secret_id;
  27. $this->secret_key = $secret_key;
  28. }
  29. /**
  30. * 客户端上传签名
  31. * 官网文档地址:https://cloud.tencent.com/document/product/266/9221
  32. * @return string
  33. */
  34. public function getUploadSign()
  35. {
  36. // 向参数列表填入参数
  37. $arg_list = [
  38. "secretId" => $this->secret_id,
  39. "currentTimeStamp" => time(),
  40. "expireTime" => time() + 86400, // 签名有效期:1天
  41. "random" => rand()
  42. ];
  43. // 计算签名
  44. $orignal = http_build_query($arg_list);
  45. $signature = base64_encode(hash_hmac('SHA1', $orignal, $this->secret_key, true).$orignal);
  46. return ResultWrapper::success($signature);
  47. }
  48. }