PHP + cURL: ошибка: информация о состоянии недопустима для этой страницы и может быть повреждена.

Я пытаюсь войти в

https://reg.viatoll.pl/PreLogin.aspx?language=po

с CURL. При ошибке я должен получить «Код подтверждения ошибки» — на польском: «Nieprawidlowy kod weryfikacyjny», но я получаю

Error: The state information is invalid for this page and might be corrupted. System.Web at System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) at...

Я не знаю, что я делаю не так. Я сообщаю, что это что-то с __VIEWSTATE и __EVENTVALIDATION. Если я открываю эту страницу в Chrome и изменяю sth в __VIEWSTATE или __EVENTVALIDATION до публикации данных, я получаю ту же ошибку.
Мой код ниже:

<?php

require_once('simple_html_dom.php'); // http://simplehtmldom.sourceforge.net/manual.htm

$cookie="cookie2.txt";

$url = 'https://reg.viatoll.pl/PreLogin.aspx?language=po';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_COOKIE, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR,$cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE,$cookie);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt ($ch, CURLOPT_REFERER, $url);
$result = curl_exec($ch);
$html = str_get_html($result);
$vs = $html->find('#__VIEWSTATE')[0]->value;
$ev = $html->find('#__EVENTVALIDATION')[0]->value;// sending data
$txtVerificationCode='asdasdas';
$txtUserName="UserName";
$txtPassword="Haselko123";
$url='https://reg.viatoll.pl/PreLogin.aspx?language=po';

$postdata = "__LASTFOCUS=&__EVENTTARGET=btnLogin&__EVENTARGUMENT=&__VIEWSTATE=".$vs."&__EVENTVALIDATION=".$ev."&txtUserName=".$txtUserName."&txtPassword=".$txtPassword."&txtVerificationCode=".$txtVerificationCode;

$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookie);  // <-- add this line
curl_setopt ($ch, CURLOPT_REFERER, $url);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);

echo "POST: " . $postdata . "<br><br><br>";

echo $result;?>

Пожалуйста, помогите кто-нибудь 🙂

1

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector