cloudflare视频转码接口怎么弄
本篇文章给大家分享的是有关cloudflare视频转码接口怎么弄,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
成都创新互联公司2013年成立,先为龙陵等服务建站,龙陵等地企业,进行企业商务咨询服务。为龙陵企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。
/** * 视频上传转码 * @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; } } /** * 获取视频转码后的状态 * @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; } } /** * 删除转码后的视频 * @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视频转码接口怎么弄,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注创新互联行业资讯频道。
本文名称:cloudflare视频转码接口怎么弄
本文路径:http://ybzwz.com/article/jppdsg.html