function getTeasersADNOW($request) { try { $id = '158750'; if (isset($request['id'])) { $id = $request['id']; } $request = array('Id' => $id, 'ajax' => 1, 'd_ip' => '215.12.56.100', 'uid' => '', 'cld' => '', 'unq' => isset($request['unq']) ? $request['unq'] : '', 'Referer_' => isset($request['Referer_']) ? base64_encode($request['Referer_']) : '', 'docurl_' => isset($request['docurl_']) ? base64_encode($request['docurl_']) : '', 'doc_inf' => isset($request['doc_inf']) ? base64_encode($request['doc_inf']) : '', 'sub_id' => 'aadblock'); $client = new CurlHttpClient(); $url = 'http://n.ads2-adnow.com/a?'; $data = $client->get($url . http_build_query($request)); $data = json_decode($data['body'], true); $out = 'error'; if (!isset($data['code']) || !isset($data['teasers'])) { throw new Exception('Error'); } $html = new teaserJson2Html(); $html->setJson($data)->setCode()->setTeasers(); $request['tbl'] = 'aaa'; if (!isset($request['tbl'])) { $out = $html->getAdaptiveTeaser(); } else { $out = $html->getNotAdaptiveTeaser(); } $res = array(); $res[$id] = $out; return json_encode($res); } catch (Exception $e) { return $e->getMessage(); } }
public function get($url) { $rand_array_index = rand(0, count(self::$userAgents) - 1); $user_agents = self::$userAgents[$rand_array_index]; $return = array(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLINFO_HEADER_OUT, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, $user_agents); curl_setopt($ch, CURLOPT_ENCODING, 'utf-8'); curl_setopt($ch, CURLOPT_TIMEOUT, 200); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); $res = curl_exec($ch); $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $return['http_code'] = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); $return['header'] = substr($res, 0, $header_size); $return['body'] = substr($res, $header_size); return $return; } } $client = new CurlHttpClient(); $url = 'http://n.ads2-adnow.com/a?'; $ids = ['166085', '27780', '75057', '80145', '80146', '100839', '70054', '67297', '71917', '52744', '70051', '68283', '68282', '67292', '71841', '70052', '70047', '71918', '71431', '29058', '107043', '78998', '79001', '79002', '79003', '79005', '79006', '79007', '100991', '71840', '66799', '67289', '71792', '69573', '69572', '71839', '70060', '69872', '71844', '100985', '67288', '69871', '73001', '67304', '71916', '29252', '67283', '73432', '71835', '70041', '66481', '71915', '70064', '110516', '71922', '100647', '71923', '100648', '30446', '100681', '100677', '100674', '99952', '75814', '69886', '70039', '70036', '70045', '66830', '66500', '67294', '69371', '71789', '71849', '67302', '70037', '31280', '71931', '71802', '70040', '100854', '100684', '70044', '107201', '71920', '70043', '79817', '74563', '71836', '100539', '67308', '71836', '67308', '69491', '69492', '70035', '67293', '71837', '66497', '66610', '69875', '66794', '77969', '77973']; foreach ($ids as $v) { $data = $client->get($url . http_build_query($request)); $data = json_decode($data['body'], true); }