'liedou', 'password' => '28IL7erA' ]; $headers = [ 'Origin:https://h5-video.shruisong.net', 'Accept-Encoding:gzip, deflate, br', 'Accept-Language:zh-CN,zh;q=0.9', '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', 'Content-Type:application/x-www-form-urlencoded;charset=UTF-8', 'Accept:application/json, text/plain, */*', 'Connection:keep-alive' ]; $res = HttpService::curl_post($url, $body, $headers); $res = json_decode($res, true); $session = null; if( (isset($res['code']) && $res['code']=='0000' && isset($res['data']['session']) )){ $session = $res['data']['session']; RedisModel::set(self::SESSION_RDS_KEY, $session); } elseif( $retry < 5) { $retry++; $session = self::setSession($retry); } if( !$session ){ Log::logError('冰甜接口调用凭证获取失败', [ 'res' => $res, 'retry' => $retry ], 'BingtSetSession'); } return $session; } public static function crawlBingtApi($url, $body=[], $retry=0) { $session = BingtianService::getSession(); if( !$session ){ return false; } $headers = [ 'Origin:https://h5-video.shruisong.net', 'Accept-Encoding:gzip, deflate, br', 'Accept-Language:zh-CN,zh;q=0.9', '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', 'Content-Type:application/x-www-form-urlencoded;charset=UTF-8', 'Accept:application/json, text/plain, */*', 'Connection:keep-alive', 'session:'. $session ]; $res = HttpService::curl_post($url, $body, $headers); $res = json_decode($res, true); if(isset($res['code']) && $res['code']=='10004' && $retry<5 ){ $retry++; //session过期,重置 RedisModel::del(BingtianService::SESSION_RDS_KEY); $res = self::crawlBingtApi($url, $body, $retry); } return $res; } }