视频上传到乐视云 在自己的网站播放
我个人理解 乐视云在这里充当了一个资源服务器 通过api取到视频链接和信息 存到自己库里 与项目进行关联 下面代码是从一位已注销的开源中国的朋友那找到的
_sendZhiboApi($param);//请求接口 return $res; } /* * 点播api * $api_name string 点播接口名 * $param array 点播参数 */ public function dianbo($api_name,$param=''){ $param['api'] = $api_name; $res = $this->_sendDianboApi($param);//请求接口 return $res; } /* * 发送直播api请求 */ protected function _sendZhiboApi($param){ $param['ver'] = $this->zhibo_ver;//直播版本号 $param['userid'] = $this->userid;//用户数字id $param['timestamp'] = time()*1000;//时间戳 毫秒 $sign = $this->_getSign($param);//获取签名 $param['sign'] = $sign; $json = $this->_curlPost($this->zhibo_apiurl,$param); $res = json_decode($json,true); return $res; } /* * 发送点播api请求 */ protected function _sendDianboApi($param){ $param['ver'] = $this->dianbo_ver;//协议版本号,统一取值为2.0 $param['user_unique'] = $this->user_unique;//用户唯一标识码,由乐视网统一分配并提供 $param['timestamp'] = time()*1000;//当前Unix时间戳 $param['format'] = 'json';//返回参数格式:支持json和xml两种方式 $sign = $this->_getSign($param);//获取签名 $param['sign'] = $sign; $json = $this->_curlPost($this->dianbo_apiurl,$param); $res = json_decode($json,true); if($res['code'] == 0){ return isset($res['data']) ? $res['data'] : true; } return false; } /* * 作用:生成签名 */ protected function _getSign($param) { //签名步骤一:按字典序排序参数 ksort($param); $String = $this->_formatBizQueryParaMap($param);//拼接数组 //签名步骤二:在string后加入KEY $String = $String.$this->secret; //签名步骤三:MD5加密 $String = md5($String); return $String; } /* * 拼接数组 */ protected function _formatBizQueryParaMap($paraMap, $urlencode = ''){ $buff = ""; ksort($paraMap); foreach ($paraMap as $k => $v){ if($urlencode){ $v = urlencode($v); } $buff .= $k . $v; } return $buff; } /* * 发送curl 请求 */ public function _curlPost($url,$data){ $ch = curl_init(); $header[] = "Accept-Charset: utf-8"; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_AUTOREFERER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $tmpInfo = curl_exec($ch); curl_close($ch); return $tmpInfo; } }
秘钥 用户ID UUID 都是乐视云后台可以看到的 通过一个算法和自己的secret 组合成一个md5加密的sign
dianbo('video.list'); var_dump($result); /** 结果array 0 => array 'video_id' => string '36950395' (length=8) 'video_unique' => string '810090111f' (length=10) 'video_name' => string '阴阳师' (length=9) 'img' => string 'http://i3.letvimg.com/lc13_yunzhuanma/201610/28/09/38/547428c7a1e48587f36c5d0969d35565_v2_NDIyMjkxNjMw/thumb/1.jpg' (length=114) 'init_pic' => string '' (length=0) 'is_pay' => string '0' (length=1) 'video_duration' => string '218' (length=3) 'initial_size' => string '57180660' (length=8) 'error_code' => string '0' (length=1) 'error_desc' => string '' (length=0) 'complete_time' => string '2016-10-28 09:36:46' (length=19) 'add_time' => string '2016-10-28 09:35:38' (length=19) 'isdrm' => string '0' (length=1) 'isdownload' => string '0' (length=1) 'video_desc' => string '' (length=0) 'tag' => string '' (length=0) 'file_md5' => string '547428c7a1e48587f36c5d0969d35565' (length=32) 'mid' => string '211145315' (length=9) 'usercategory1' => string '37869' (length=5) 'usercategory2' => string '37870' (length=5) 'status' => string '10' (length=2) */
很简单 获取的是视频列表 没有参数 需要获取其他信息的 根据方法传对应的值