本篇文章给大家分享的是有关美国云火炬视频转码接口怎么弄,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
/**
*视频上传转码
*@param$video_url
*@param$vide_name
*/
publicationstaticfunctionpost video($ video _ URL,$vide_name)
{
需要_一次(__DIR__).'/././common/libs/requests/library/requests。PHP’);
\ request 3360: register _ auto loader();
$ headers=数组(
x-Auth-Key '=yii : $ app-params[' cf _ Key '],
x-Auth-Email '=yii : $ app-params[' cf _ Email ']
);
$ URL=' https://API。云耀斑。com/client/v4/accounts/'。yii : $ app-params[' cf _ account _ id ']./stream/copy ';
$ data="{"URL": " .$video_url .' meta':{'name': ' ' .$vide_name .'}}';
$ response=\ request 3360: POSt($ URL,$headers,$ data);
$ PostDATa=JSON _ decode($ response-body);
if($ PostDATa-success){ 0
返回$ postData
}else{
returnfalse
}
}
/**
*获取视频转码后的状态
* @ paramstringn
bsp;$videoCode
* @return bool|mixed
*/
public static function getVideoStatus($videoCode)
{
require_once(__DIR__ . '/../../common/libs/requests/library/Requests.php');
\Requests::register_autoloader();
$headers = array(
'X-Auth-Key' => Yii::$app->params['cf_key'],
'X-Auth-Email' => Yii::$app->params['cf_email'],
'Content-Type' => 'application/json'
);
$url = "https://api.cloudflare.com/client/v4/accounts/".Yii::$app->params['cf_account_id']."/media/{$videoCode}";
$response = \Requests::get($url, $headers);
$postData = json_decode($response->body);
if($postData->success){
return $postData;
}else{
return false;
}
}
/**
* 删除转码后的视频
* @param string $videoCode
* @return bool
*/
public static function delVideo($videoCode)
{
require_once(__DIR__ . '/../../common/libs/requests/library/Requests.php');
\Requests::register_autoloader();
$headers = array(
'X-Auth-Key' => Yii::$app->params['cf_key'],
'X-Auth-Email' => Yii::$app->params['cf_email'],
'Content-Type' => 'application/json'
);
$url = "https://api.cloudflare.com/client/v4/zones/".Yii::$app->params['cf_zone_id']."/media/{$videoCode}";
$response = \Requests::delete($url, $headers);
if($response->status_code == 200){
return true;
}else{
return false;
}
}
以上就是cloudflare视频转码接口怎么弄,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注行业资讯频道。
内容来源网络,如有侵权,联系删除,本文地址:https://www.230890.com/zhan/37454.html