[Hilfe] webrequest login...

06/02/2014 00:44 djklesk#1
hallo liebe community bröchte mal etwas hilfe .. keine ahnung was ich falsch mache evtl ist einfach zu spät...
jedenfalls gelingt mein kein login

PHP Code:

            string Content
;
            
CookieContainer cookieContainer = new CookieContainer();
            
string loginData "vb_login_username=******&vb_login_password=&s=&securitytoken=guest&do=login&vb_login_md5password=b80c73d0ae3d****************&vb_login_md5password_utf=b80c73******************";

            
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://mygully.com/login.php?do=login");
            
req.CookieContainer cookieContainer;
            
req.ContentType "application/x-www-form-urlencoded";
            
req.Method "Post";
            
byte[] loginDataBytes Encoding.GetEncoding("ISO-8859-1").GetBytes(loginData);
            
req.ContentLength loginDataBytes.Length;
            
System.IO.Stream stream req.GetRequestStream();
            
stream.Write(loginDataBytes0loginDataBytes.Length);
            
stream.Close();
            
HttpWebResponse res = (HttpWebResponse)req.GetResponse();

            
req = (HttpWebRequest)HttpWebRequest.Create(url);
            
req.CookieContainer cookieContainer;
            
req.Method "GET";
            
res = (HttpWebResponse)req.GetResponse(); 
PHP Code:
http://mygully.com/login.php?do=login

POST /login.php?do=login HTTP/1.1
Host
mygully.com
User
-AgentMozilla/5.0 (Windows NT 6.1WOW64rv:29.0Gecko/20100101 Firefox/29.0
Accept
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: mygully.com
Cookie: __utma=***************; __utmz=************.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); __utmc=************; bbsessionhash=***************; bblastvisit=1401653384; bblastactivity=0; __utmb=********.3.10.*******; bbthread_lastview=*********-1-%7Bi-3334689_i-1401653030_%7D
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 188
vb_login_username=********&vb_login_password=&s=&securitytoken=guest&do=login&vb_login_md5password=***********&vb_login_md5password_utf=***********
HTTP/1.1 200 OK
Server: nginx
Date: Sun, 01 Jun 2014 21:10:07 GMT
Content-Type: text/html; charset=ISO-8859-1
Transfer-Encoding: chunked
Connection: keep-alive
x-powered-by: PHP/5.3.0
Set-Cookie: ********; path=/; HttpOnly
Set-Cookie: *********; expires=Mon, 01-Jun-2015 21:00:13 GMT; path=/
Set-Cookie: ***************015 21:00:13 GMT; path=/
Set-Cookie: *********3 21:00:12 GMT; path=/
Cache-Control: private
Pragma: private
x-ua-compatible: IE=7
Content-Encoding: gzip 
06/02/2014 01:36 tolio#2
klassiker, erst cookies etc von der login seite holen und anschließend den post zum einloggen senden

wenn du dich per hand einloggst fängt dein browser ja auch nicht mit dem login post an sondern zuerst geht man auf die seite
07/10/2014 15:58 Onkelmat#3
also seite einmal anfragen mit nem request, vorher eine cookiecontainer erstellen
Cookiecontainer cookie = new CookieContainer();

und dann im zweiten request
request.CookieContainer = cookie;