Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to do cloudflare Video Transcoding Interface

Shulou Source: shulou.com Published: 2022-06-02 02:19:49 10月27日 Update

What this article shares with you is how to do the cloudflare video transcoding interface. The editor thinks it is very practical, so I hope you can get something after reading this article. Let's take a look at it with the editor.

/ * Video upload transcoding * @ 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 (' Yii::$app- > params ['cf_key'],' Xmai AuthlyEmail' = > 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 }} / * obtain the video transcoding status * @ 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 (' Yii::$app- > params ['cf_key'],' Content-Type' = > application/json'], '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 }} / * Delete the transcoded video * @ param string $videoCode * @ return bool * / public static function delVideo ($videoCode) {require_once (_ _ DIR__. '/.. / common/libs/requests/library/Requests.php');\ Requests::register_autoloader (); $headers = array (' Yii::$app- > params ['cf_key'],' Content-Type' = > application/json'], '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 }} the above is how to do the cloudflare video transcoding interface. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Tags: Videos interfaces more knowledge articles practical that is work meetings articles status look knowledge points industry details information information channels follow parts channels learning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Linux Shulou Information NVidia Apple