sign的生成算法还是比较简单的,话不多说直接上成品。
<?php header("content:application/json;charset=uft-8"); $res=new miandan(); $type= $_GET@['type']; $page=$_GET@['page']; $cartoonId=$_GET@['cartoonId']; $chapterId=$_GET@['chapterId']; $sortName=$_GET@['sortName']; if($type==1){ echo $res->getList($page,$sortName); }elseif ($type==2){ echo $res->getChapterList($cartoonId); }elseif ($type==3){ echo $res->getChapterInfo($cartoonId,$chapterId); } class miandan{ private array $header; private string $token; private string $sign; private string $timestamp; private string $device; public $POST; function __construct() { $this->receive_json_to_array(); $this->setHeader(); } private function receive_json_to_array() { $json = file_get_contents('php://input'); //加true转换为数组,不加转换为对象 $this->POST = json_decode($json, true); } private function setHeader(){ $this->token="12350842137b9dc6dd107cf6b9ee25a549fade8df4012a340657c850bdcfd660c46ccc6ae0394a4d58b97d9367a8c087d3b6b1f2eb26e87904cd3482358509f5209e5d61f5d4caf5"; $this->device="9B51FC6326CCB48B1A106F770428C65F5848AEF8"; $this->header = array( 'Content-Type: application/json;charset=utf-8', 'auth_token: '.$this->token, 'deviceUnique: '.$this->device, 'deviceType: 1', 'phoneType: OnePlusA5010', 'clientVersion: 2.9.2', 'marketName: other', 'spreadId: 0', 'phoneSystemVersion: 5.1.1', 'shareId: 0', 'shareType: 0', 'imei: 852637142262151', 'androidid: 96c1d98e32c54f58', 'Host: app.xx.cn', 'Connection: Keep-Alive', 'User-Agent: okhttp/3.11.0' ); } /** * @param $type 1 列表算法 2 章节详情算法 * @param int $cartoonId 漫画id * @param int $chapterId 章节id * @return string 返回sign */ public function getSign($type, int $cartoonId=0, int $chapterId=0): string { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://app. 域名. cn/api/lifan-cartoon/chapter/get/timestamp"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, $this->header); // curl_setopt($ch, CURLOPT_POSTFIELDS, $urls); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $data = curl_exec($ch); curl_close($ch); $json= json_decode($data,true); if($type==1){ $sign=md5("mark=miandan888×tamp=".$json['data']."&token=$this->token"); }elseif ($type==2){ $sign=md5("cartoonId=$cartoonId&chapterId=$chapterId&mark=fanLi888×tamp=".$json['data']."&token=$this->token"); } $this->timestamp=$json['data']; $this->sign=$sign; $res=array('sign'=>$sign,'timestamp'=>$json['data']); return json_encode($res); } private function postUrl($url,$data){ $data = json_encode($data); $headerArray =$this->header; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,FALSE); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl,CURLOPT_HTTPHEADER,$headerArray); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($curl); curl_close($curl); return json_decode($output,true); } /**获取漫画列表 * @param int $page 漫画列表页数 * @param string $sortName 排序名称 默认 hot人气 * @return false|string 返回json */ public function getList(int $page=1,$sortName='hot'){ $this->getSign(1); $data=array( 'pageSize'=>10, 'pageNum'=>$page, 'themeId'=>'', 'area'=>'', 'fullflag'=>'', 'gender'=>'', 'category'=>'', 'isfree'=>'', 'sortName'=>'hot', 'content'=>'', 'sign'=>$this->sign, 'timestamp'=>$this->timestamp, 'labelId'=>null ); $res=$this->postUrl('https://app. 域名. cn/api/lifan-cartoon/cartoon/find/page2',$data); return json_encode($res); } /**获取漫画章节 * @param $cartoonId @漫画id * @return false|string 返回json */ public function getChapterList($cartoonId){ $data=array( "pageSize"=>"", "pageNum"=>"", "cartoonId"=>$cartoonId ); $res=$this->postUrl("https://app. 域名. cn/api/lifan-cartoon/chapter/find/page",$data); return json_encode($res); } /**获取漫画章节详情 * @param int $cartoonId 漫画id * @param int $chapterId 章节id * @return false|string */ public function getChapterInfo(int $cartoonId, int $chapterId){ $this->getSign(2,$cartoonId,$chapterId); $data=array( "chapterId"=>$chapterId, "headerUrl"=>"http://ossmh.xx.cn/customer/prod/headerUrl/5533836.png?update=2021-12-30T17:30:04", "customerName"=>"用户", "deviceUnique"=>$this->device, "sign"=>$this->sign, "cartoonId"=>$cartoonId, "timestamp"=>$this->timestamp ); $res=$this->postUrl("https://app. 域名. cn/api/lifan-cartoon/chapter/find/chapter/detail/anti-reptile",$data); return json_encode($res); }}