标签:字典序 protect 自己 es2017 blog data 代码 exec length
视频上传到乐视云 在自己的网站播放
我个人理解 乐视云在这里充当了一个资源服务器 通过api取到视频链接和信息 存到自己库里 与项目进行关联 下面代码是从一位已注销的开源中国的朋友那找到的
1 2 /* 3 * 作用:生成签名 4 */ 5 protected function _getSign($param) 6 { 7 //签名步骤一:按字典序排序参数 8 ksort($param); 9 10 $String = $this->_formatBizQueryParaMap($param);//拼接数组 11 12 //签名步骤二:在string后加入KEY 13 $String = $String.$this->secret; 14 15 //签名步骤三:MD5加密 16 $String = md5($String); 17 18 return $String; 19 } 20 21 /* 22 * 拼接数组 23 */ 24 protected function _formatBizQueryParaMap($paraMap, $urlencode = ‘‘){ 25 $buff = ""; 26 ksort($paraMap); 27 foreach ($paraMap as $k => $v){ 28 if($urlencode){ 29 $v = urlencode($v); 30 } 31 $buff .= $k . $v; 32 } 33 return $buff; 34 } 35 36 /* 37 * 发送curl 请求 38 */ 39 public function _curlPost($url,$data){ 40 41 $ch = curl_init(); 42 $header[] = "Accept-Charset: utf-8"; 43 curl_setopt($ch, CURLOPT_URL, $url); 44 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 45 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 46 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 47 curl_setopt($ch, CURLOPT_HTTPHEADER, $header); 48 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 49 curl_setopt($ch, CURLOPT_AUTOREFERER, 1); 50 curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 51 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 52 $tmpInfo = curl_exec($ch); 53 curl_close($ch); 54 55 return $tmpInfo; 56 } 57 58 }
秘钥 用户ID UUID 都是乐视云后台可以看到的 通过一个算法和自己的secret 组合成一个md5加密的sign
1 <?php 2 3 require_once ‘getsign.php‘; 4 $LeshiController = new LeshiController(); 5 $result = $LeshiController->dianbo(‘video.list‘); 6 var_dump($result); 7 /** 结果 8 array 9 0 => 10 array 11 ‘video_id‘ => string ‘36950395‘ (length=8) 12 ‘video_unique‘ => string ‘810090111f‘ (length=10) 13 ‘video_name‘ => string ‘阴阳师‘ (length=9) 14 ‘img‘ => string ‘http://i3.letvimg.com/lc13_yunzhuanma/201610/28/09/38/547428c7a1e48587f36c5d0969d35565_v2_NDIyMjkxNjMw/thumb/1.jpg‘ (length=114) 15 ‘init_pic‘ => string ‘‘ (length=0) 16 ‘is_pay‘ => string ‘0‘ (length=1) 17 ‘video_duration‘ => string ‘218‘ (length=3) 18 ‘initial_size‘ => string ‘57180660‘ (length=8) 19 ‘error_code‘ => string ‘0‘ (length=1) 20 ‘error_desc‘ => string ‘‘ (length=0) 21 ‘complete_time‘ => string ‘2016-10-28 09:36:46‘ (length=19) 22 ‘add_time‘ => string ‘2016-10-28 09:35:38‘ (length=19) 23 ‘isdrm‘ => string ‘0‘ (length=1) 24 ‘isdownload‘ => string ‘0‘ (length=1) 25 ‘video_desc‘ => string ‘‘ (length=0) 26 ‘tag‘ => string ‘‘ (length=0) 27 ‘file_md5‘ => string ‘547428c7a1e48587f36c5d0969d35565‘ (length=32) 28 ‘mid‘ => string ‘211145315‘ (length=9) 29 ‘usercategory1‘ => string ‘37869‘ (length=5) 30 ‘usercategory2‘ => string ‘37870‘ (length=5) 31 ‘status‘ => string ‘10‘ (length=2) 32 */
很简单 获取的是视频列表 没有参数 需要获取其他信息的 根据方法传对应的值
标签:字典序 protect 自己 es2017 blog data 代码 exec length
原文地址:http://www.cnblogs.com/niniko/p/7592600.html