L
L
libera2015-12-20 21:29:05
Delphi
libera, 2015-12-20 21:29:05

Post request fails?

var
LoginData, Response: TStrings;
begin
LoginData := TStringList.Create;
Response := TStringList.Create;
Response.Text := idhtp1.Post('http://www.сайт.ru/vop/en/members/login.aspx?id=15',LoginData);
idhtp1.HandleRedirects:=true;
idhtp1.RedirectMaximum:=1;
LoginData.Add('TextBox1=пороль');
LoginData.Add('TextBox2=логин');
LoginData.Add('__VIEWSTATE=/wEPDwUJLTI0MTE1Nzg3D2QWBAIBD2QWAgIHDw8WAh4HVmlzaWJsZWhkZAIDDw8WAh4EVGV4dGVkZGR2NFVBFeEeY71EBQHL03G6jJXuxQ==');
LoginData.Add('__VIEWSTATEGENERATOR=261583EA');
LoginData.Add('__EVENTVALIDATION=/wEWBAL/+amRAgLs0bLrBgLs0fbZDAKM54rGBnsveKYDayDMIAFMQZrF5+2kIAdA');
LoginData.Add('Button1=submit');
if Pos ('logout',Response.Text)<> 0 then
lbl1.Caption :=  'Успешная авторизация'
else
lbl1.Caption:= 'Авторизация не удалась' ;
end;

It does not write authorization failed.
If you remove idhtp1.RedirectMaximum:=1;
That is http 405 error

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
ORTOL, 2015-12-24
@ORTOL

Hello.

LoginData.Add('__VIEWSTATE=/wEPDwUJLTI0MTE1Nzg3D2QWBAIBD2QWAgIHDw8WAh4HVmlzaWJsZWhkZAIDDw8WAh4EVGV4dGVkZGR2NFVBFeEeY71EBQHL03G6jJXuxQ==');
LoginData.Add('__VIEWSTATEGENERATOR=261583EA');
LoginData.Add('__EVENTVALIDATION=/wEWBAL/+amRAgLs0bLrBgLs0fbZDAKM54rGBnsveKYDayDMIAFMQZrF5+2kIAdA');

I don't like these lines... Something tells me that the values ​​in them are dynamic. If you are trying to register only using this algorithm, then you are wrong. Typically, such operations are carried out in 2 accounts ...
Account number 1. You must programmatically go through the link of the registration page, thereby writing dynamic values ​​\u200b\u200bto variables (sessions, tokens, cookies), etc. in short, the dynamic information that you need for registration.
Score number 2. And only then execute the above code BUT having already entered the values ​​​​of the variables there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question