You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.0 KiB
65 lines
2.0 KiB
<?php
|
|
|
|
// This file is auto-generated, don't edit it. Thanks.
|
|
namespace service;
|
|
|
|
use AlibabaCloud\SDK\Vod\V20170321\Vod;
|
|
use AlibabaCloud\Tea\Utils\Utils;
|
|
use AlibabaCloud\Tea\Exception\TeaError;
|
|
use Darabonba\OpenApi\Models\Config;
|
|
use AlibabaCloud\SDK\Vod\V20170321\Models\GetPlayInfoResponse;
|
|
use AlibabaCloud\SDK\Vod\V20170321\Models\GetPlayInfoRequest;
|
|
|
|
class AliVodServices {
|
|
|
|
/**
|
|
* @param string $regionId
|
|
* @return Vod
|
|
*/
|
|
public static function Initialization($regionId){
|
|
$config = new Config([]);
|
|
// 您的AccessKey ID
|
|
$config->accessKeyId = SystemConfigService::get('accessKeyId');
|
|
// 您的AccessKey Secret
|
|
$config->accessKeySecret =SystemConfigService::get('accessKeySecret');
|
|
// 您的可用区ID
|
|
$config->regionId = $regionId;
|
|
return new Vod($config);
|
|
}
|
|
|
|
/**
|
|
* @param Vod $client
|
|
* @param string $videoId
|
|
* @return GetPlayInfoResponse
|
|
*/
|
|
public static function GetPlayInfoSample($client, $videoId){
|
|
$request = new GetPlayInfoRequest([]);
|
|
// 视频ID。
|
|
$request->videoId = $videoId;
|
|
$request->formats= 'm3u8';
|
|
$response = $client->getPlayInfo($request);
|
|
return $response;
|
|
}
|
|
|
|
/**
|
|
* @param string[] $args
|
|
* @return void
|
|
*/
|
|
public static function main($args){
|
|
try {
|
|
$regionId = @$args[0];
|
|
$videoId = @$args[1];
|
|
$client = self::Initialization($regionId);
|
|
$responseGetPlayInfo = self::GetPlayInfoSample($client, $videoId);
|
|
return $responseGetPlayInfo->body->playInfoList->playInfo[0]->playURL;
|
|
// return Utils::toJSONString(Utils::toMap($responseGetPlayInfo));
|
|
}
|
|
|
|
catch (\Throwable $error) {
|
|
if (!($error instanceof TeaError)) {
|
|
$error = new TeaError([], $error->getMessage(), $error->getCode(), $error);
|
|
}
|
|
return $error->message ;
|
|
}
|
|
}
|
|
}
|
|
|