Новый участник
Сообщения: 44
Благодарности: 7
|
Профиль
|
Отправить PM
| Цитировать
Все заработало. Оказалось, что если указывать не верный идентификатор браузера, форма не возвращается.
указан был фаерфокс, а я тестил через хром и ИЕ6. Поставил USERAGENT Интернет Эксплорера 6го и в нем все заработало.
В итоге просто закоментил указание USERAGENT и все заработало в обоих браузерах.
Вот конечный вариант функции для пост запроса через прокси:
PHP код: ![Выделить весь код](images/misc/selectcode.png)
function post_content ($url,$postdata) { $uagent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)";
$ch = curl_init( $url ); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_PROXY, 'x.x.x.x:8080'); curl_setopt($ch, CURLOPT_PROXYUSERPWD,'xxx:xxx'); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_ENCODING, ""); // curl_setopt($ch, CURLOPT_USERAGENT, $uagent); curl_setopt($ch, CURLOPT_TIMEOUT, 120); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_AUTOREFERER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt($ch, CURLOPT_COOKIEJAR, "d://coo.txt"); curl_setopt($ch, CURLOPT_COOKIEFILE,"d://coo.txt");
$content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch );
$header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; return $header; }
//(c) parsing-and-i.blogspot.com
|
Отправлено: 18:06, 16-03-2012
| #4
|