$accountInfo, 'res' => $res, 'retry' => $retry ], 'DongFangSetSession'); } return $session; } public static function crawlDongFangApi($url, $accountInfo, $body=[], $retry=0) { # 获取session $session = DongFangService::getSession($accountInfo); if( !$session ){ return false; } $headers = [ // 'Accept: application/json, text/plain, */*', // 'Accept-Encoding: gzip, deflate, br', // 'Accept-Language: zh-CN,zh;q=0.9', // 'Connection: keep-alive', // 'Content-Type: application/x-www-form-urlencoded;charset=UTF-8', // 'Host: video-wechat-open.eastdrama.com', // 'Origin: https://m.eastdrama.com', // 'sec-ch-ua: "Chromium";v="106", "Google Chrome";v="106", "Not;A=Brand";v="99"', // 'sec-ch-ua-mobile: ?0', // 'sec-ch-ua-platform: "Windows"', // 'Sec-Fetch-Dest: empty', // 'Sec-Fetch-Mode: cors', // 'Sec-Fetch-Site: same-site', 'session: '. $session, // 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36' ]; $res = HttpService::httpPost($url, json_encode($body), TRUE, $headers); Log::logInfo('test', [$res], 'DongFangApi'); $res = json_decode($res, true); if(isset($res['code']) && (in_array($res['code'], ['10003', '10004'])) && $retry<5 ){ $retry++; //session过期,重置 RedisModel::del(DongFangService::SESSION_RDS_KEY.'-'.$accountInfo['username']); $res = self::crawlDongFangApi($url, $accountInfo, $body, $retry); } return $res; } // public static function }