Autor Beitrag
Airtrox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 109


Delphi 7
BeitragVerfasst: Fr 11.12.09 14:56 
Hallo,

ich möchte mich via idhttp auf eine Seite einloggen. Die Post Daten habe ich mit HttpFox ausgelesen, jedoch finde ich sie etwas komisch:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
-----------------------------14688134019749
Content-Disposition: form-data; name="email"

die_email
-----------------------------14688134019749
Content-Disposition: form-data; name="password"

das_passwort
-----------------------------14688134019749
Content-Disposition: form-data; name="action"

Login
-----------------------------14688134019749--

Das gibt er unter Raw aus, unter Pretty sieht es dann so aus:
ausblenden Quelltext
1:
2:
3:
email=die_email
password=das_passwort
action=Login


Wenn ich diese Daten (in einer stringlist) an die entsprechende Seite weitergebe, schlägt der Login fehl.

Die obigen Nummern finde ich übrigens nirgends im Quelltext.

Falls der Quelltext helfen könnte:
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
          <FORM ACTION="/?p=userarea&location=login" ENCTYPE="multipart/form-data" METHOD="POST" NAME="login_form" STYLE="display: inline;" onSubmit="window.setTimeout('DisableForm(\''+this.name+'\');', 1); return(true);">
            <TABLE CLASS="FORM" BORDER="0" CELLSPACING="1" CELLPADDING="0" WIDTH="646">
              <TR>
                <TH ALIGN="LEFT" WIDTH="644">

                  <H1>Mitglieder Login</H1>
                </TH>
              </TR>
              <TR>
                <TD ALIGN="CENTER" WIDTH="644">
                  <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="5" STYLE="margin-top: 5px; margin-bottom: 5px;">
                    <TR>
                      <TD ALIGN="RIGHT" WIDTH="150"></TD>

                      <TD ALIGN="LEFT">
                        <P STYLE="width: 400px;"><SPAN CLASS="SUCCESS">Bitte geben Sie Ihre Login Daten an.</SPAN></P>
                      </TD>
                    </TR>
                    <TR>
                      <TD ALIGN="CENTER" COLSPAN="2"><HR></TD>
                    </TR>
                    <TR>

                      <TD ALIGN="RIGHT">
                        <P><B>E-Mail Adresse:</B></P>
                      </TD>
                      <TD ALIGN="LEFT">
                        <INPUT TYPE="TEXT" CLASS="TEXT" NAME="email" MAXLENGTH="64" SIZE="55" STYLE="width: 320px;" VALUE="" onFocus="this.select(); return(true);">
                      </TD>
                    </TR>
                    <TR>

                      <TD ALIGN="RIGHT">
                        <P><B>Passwort:</B></P>
                      </TD>
                      <TD ALIGN="LEFT">
                        <INPUT TYPE="PASSWORD" CLASS="TEXT" NAME="password" MAXLENGTH="64" SIZE="55" STYLE="width: 320px;" VALUE="" onFocus="this.select(); return(true);">
                      </TD>
                    </TR>
                    <TR>

                      <TD ALIGN="CENTER" COLSPAN="2"><HR></TD>
                    </TR>
                    <TR>
                      <TD ALIGN="RIGHT">
                        <P> </P>
                      </TD>
                      <TD ALIGN="LEFT">
                        <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="320">
                          <TR>

                            <TD ALIGN="RIGHT">
                              <INPUT TYPE="SUBMIT" CLASS="BUTTON" NAME="action" STYLE="width: 76px;" VALUE="Login">
                            </TD>
                          </TR>
                        </TABLE>
                      </TD>
                    </TR>
                  </TABLE>
                </TD>

              </TR>
            </TABLE>
            </FORM>




Liegt das nun an der Seite, oder an diesen merkwürdigen Zahlen (oben). Diese verändern sich übrigens jedes mal wenn ich mich einlogge.
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Fr 11.12.09 15:17 
Ich glaube, dein Code könnte da eher helfen..

_________________
PROGRAMMER: A device for converting coffee into software.
Airtrox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 109


Delphi 7
BeitragVerfasst: Fr 11.12.09 15:33 
an meinem code ist eigentlich nichts umgewöhnliches:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
var list : tstringlist;
    code : string;
begin
  form1.IdHTTP1.AllowCookies := true;
  form1.IdHTTP1.HandleRedirects := true;
  form1.IdHTTP1.Request.UserAgent := 'Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10';
  list := tstringlist.create;
try
      list.Add('email='+edit1.text);
      list.Add('password='+edit2.text);
      list.add('action=Login');
      code :=  form1.idhttp1.post('http://****/?p=userarea&location=account', list);
      if (pos('Willkommen', code) = 0then showmessage('Erfolgreich'else showmessage('Nicht erfolgreich');
finally
      list.Free;
end;
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Fr 11.12.09 15:40 
Hast du auch nen CookieManager, oder wie das Ding heißt?

_________________
PROGRAMMER: A device for converting coffee into software.
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Fr 11.12.09 15:42 
Man sollte in solchen Fällen auch mal den Content-Type mitlesen ;)

ausblenden XML-Daten
1:
<FORM ACTION="/?p=userarea&location=login" ENCTYPE="multipart/form-data" METHOD="POST" NAME="login_form" STYLE="display: inline;" onSubmit="window.setTimeout('DisableForm(\''+this.name+'\');', 1); return(true);">					


Damit dein Request genauso aussieht, musst du (wie auch immer, Dok lesen hilft) dem IdHTTP sagen dass er genau diesen verwenden soll.
Das tut aber eigentlich nichts zur Sache, da das eh nur für die Übertragung eine Rolle spielt.

Dein Problem dürfte tatsächlich eher das sein:
user profile iconXentar hat folgendes geschrieben Zum zitierten Posting springen:
Hast du auch nen CookieManager, oder wie das Ding heißt?

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Airtrox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 109


Delphi 7
BeitragVerfasst: Fr 11.12.09 16:01 
Ich habe es mal mit dem IdCookieManager ausprobiert(auch bei idhttp angegeben), jedoch klappt es immer noch nicht.

edit: beim cookiemanager habe ich das angegeben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.IdCookieManager1NewCookie(ASender: TObject;
  ACookie: TIdCookieRFC2109; var VAccept: Boolean);
begin
acookie.Path := '\'
end;
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Fr 11.12.09 16:46 
user profile iconAirtrox hat folgendes geschrieben Zum zitierten Posting springen:
edit: beim cookiemanager habe ich das angegeben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.IdCookieManager1NewCookie(ASender: TObject;
  ACookie: TIdCookieRFC2109; var VAccept: Boolean);
begin
acookie.Path := '\'
end;


Und warum?

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Airtrox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 109


Delphi 7
BeitragVerfasst: Fr 11.12.09 20:49 
gebe ich es nicht an, klappt der login auch nicht...
Airtrox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 109


Delphi 7
BeitragVerfasst: Mi 03.02.10 23:01 
vielleicht kann sich jemand noch mal meinem Problem antun:

Ich habe wieder gesendete Post Daten unter HttpFox(Raw)
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
-----------------------------4041360224350
Content-Disposition: form-data; name="title"

TITEL
-----------------------------4041360224350
Content-Disposition: form-data; name="group"

1
-----------------------------4041360224350
Content-Disposition: form-data; name="description"

BESCHREIBUNG

Unter Pretty sieht es dann wieder ganz normal aus (title=TITLE usw)

Ich habe noch etwas gegooglet und herausgefunden, dass TIdMultiPartFormDataStream dafür geeignet wäre. Ob das nun klappt bzw. wie habe ich bisher nicht rausgefunden. Wäre super, wenn ihr mir helfen könntet, dieses Problem treibt mich noch in den Wahnsinn :evil:

edit: Ich hab es nochmal mit IDHttp versucht, Request.ContentType := 'multipart/form-data';
aber leider klappt es immer noch nicht....
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: So 07.02.10 12:52 
du musst in den CookieManager nichts reinschreiben sondern den CookieManager mit deiner HTTP Komponente verbinden!

_________________
In the beginning was the word.
And the word was content-type: text/plain.