您好,登錄后才能下訂單哦!
本篇文章給大家分享的是有關(guān)cloudflare視頻轉(zhuǎn)碼接口怎么弄,小編覺得挺實用的,因此分享給大家學(xué)習,希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。
/** * 視頻上傳轉(zhuǎn)碼 * @param $video_url * @param $vide_name */ public static function postVideo($video_url, $vide_name) { 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'] ); $url = "https://api.cloudflare.com/client/v4/accounts/".Yii::$app->params['cf_account_id']."/stream/copy"; $data = '{"url":"' . $video_url . '","meta":{"name":"' . $vide_name . '"}}'; $response = \Requests::post($url, $headers, $data); $postData = json_decode($response->body); if ($postData->success) { return $postData; } else { return false; } } /** * 獲取視頻轉(zhuǎn)碼后的狀態(tài) * @param string $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; } } /** * 刪除轉(zhuǎn)碼后的視頻 * @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視頻轉(zhuǎn)碼接口怎么弄,小編相信有部分知識點可能是我們?nèi)粘9ぷ鲿姷交蛴玫降摹OM隳芡ㄟ^這篇文章學(xué)到更多知識。更多詳情敬請關(guān)注億速云行業(yè)資訊頻道。
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。