Добрый день есть такой код написанный на jQuery: Код (Text): $.ajax({type:'POST',url:'http://host.ru/getresult.php',data:request,dataType:'json',traditional:true,error:function(){ /*тут обработка ответа*/ }); data - массив с параметрами, при отправке выглядит так "locale=ru&cityId=345&countryId=166775&departureDateMin=21.01.2012&departureDateMax=28.01.2012&nightsMin=7&nightsMax=15&adults=2&children=0&priceMin=0&priceMax=15000¤cy=5561&findByPrice=true&tourId=9009296&tourId=9009296%2C169028&hotelClassId=9006279&hotelClassId=9006280&hotelClassId=9006281&feedId=9006288&feedId=9006289&hotelInStop=false&noTicketsTo=false&noTicketsFrom=false&version=2" сам заголовок вот так: "Accept application/json, text/javascript, */* Accept-Charset windows-1251,utf-8;q=0.7,*;q=0.7 Accept-Encoding gzip, deflate Accept-Language ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3 Connection keep-alive Content-Length 393 Content-Type application/x-www-form-urlencoded; charset=UTF-8 Host ruban.pro Referer http://ruban.pro/turt/ User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1 X-Requested-With XMLHttpRequest" надо переписать отправку на php пробовал 2-мя способаси. 1-й Код (Text): $context = stream_context_create(array( } 'http' => array( 'method' => 'POST', 'header' => 'Accept application/json, text/javascript, */*' . PHP_EOL . 'Accept-Charset windows-1251,utf-8;q=0.7,*;q=0.7' . PHP_EOL . 'Accept-Encoding gzip, deflate' . PHP_EOL . 'Accept-Language ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3' . PHP_EOL . 'Connection keep-alive' . PHP_EOL . 'Content-Length 369' . PHP_EOL . 'Content-Type application/x-www-form-urlencoded; charset=UTF-8' . PHP_EOL . 'Host json.teztour.com' . PHP_EOL . 'Referer http://json.teztour.com/static/ats/search_ru.html' . PHP_EOL . 'X-Requested-With XMLHttpRequest' . PHP_EOL . 'Content-Type: text/javascript' . PHP_EOL, 'user_agent' => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1' . PHP_EOL, 'content' => 'locale=ru&cityId=521&countryId=166775&departureDateMin=21.01.2012&departureDateMax=28.01.2012&nightsMin=7&nightsMax=15&adults=2&children=0&priceMin=0&priceMax=15000¤cy=5561&findByPrice=true&tourId=9009296&hotelClassId=9006279&hotelClassId=9006280&hotelClassId=9006281&feedId=9006288&feedId=9006289&hotelInStop=false&noTicketsTo=false&noTicketsFrom=false&version=2', ), )); echo file_get_contents('http://json.teztour.com/agencytoursearch/getResult', $use_include_path = false,$context); 2-й Код (Text): $query = ''; foreach($_POST as $key => $value) { $query .= $key.'='.$value.'&'; } echo $query; $ch = curl_init(); //curl_setopt($ch, CURLOPT_PROXY, "1.2.3.4:123"); //если нужен прокси curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, "http://json.teztour.com/agencytoursearch/getResult"); //куда шлем curl_setopt($ch, CURLOPT_POSTFIELDS, $query); //что шлем curl_setopt($ch, CURLOPT_REFERER, "http://ruban.pro/turt/"); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; MyIE2; .NET CLR 1.1.4322)"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_NOBODY, 0); $result=curl_exec ($ch); curl_close ($ch); echo $result; что не так делаю?
С курлом разобрался, теперь другой вопрос сервер отправляет строку post запроса такого вида: locale=ru& cityId=345& countryId=166775& departureDateMin=21.01.2012& departureDateMax=28.01.2012& nightsMin=7& nightsMax=15& adults=2& children=0& priceMin=0& priceMax=15000& currency=5561& findByPrice=true& tourId=9009296&hotelClassId=9006279& hotelClassId=9006280& hotelClassId=9006281& feedId=9006288& feedId=9006289& hotelInStop=false& noTicketsTo=false& noTicketsFrom=false& version=2 как можно заметить в строке запроса параметры за названием feedId, hotelClassId присутствуют не однократно как мне в моем скрипте получить не массив пост а исходную строку post запроса?
Код (Text): <?php $postParams = 'param1=1¶m2=2¶m3=3¶m3=3'; $postParams = implode('&', array_unique(explode('&', $postParams)));
строку взял не посредственно на стороне сервера. но код править там нельзя=( получил post строку в исходном виде с помощью file_get_content('php://input');