login to http website java -


i trying login http website first time , having hard time understanding proper format sending arguments. have looked @ other examples , don't seem work me thought see if can explain me. @ point code seems absolutely nothing here is...

httpurlconnection url= (httpurlconnection)new url("http://www.myameego.com/index2.php?do=login").openconnection(); url.setdooutput(true); url.setrequestmethod("post"); outputstreamwriter writer = new outputstreamwriter(url.getoutputstream()); writer.write("x-mapping-fjhppofk=6a991610ba398b3a39f4b491d5382bb4; phpsessid=kbo25e08t3qvu08l1shkq8kk94; username=coled; pass=ed45d626b07112a8a501d9672f3b92796a6754b8d8d9cb4c617fec9774889220; clientid=129; x-mapping-fjhppofk=dce62fe972e1ef2f12d0060ec74c3681; phpsessid=ukeo21oldb5pqsntu7kl8j3b96"); writer.flush(); 

i downloaded http sniffer thinking read browser sending. how got write() line, cookie sent explorer. viewed source code login screen , found block of code near bottom looks responsible login.

http://www.myameego.com/index2.php?do=login

can tell me how go hooking interface don't understand how works. if helps full packet manual login through browser. got http sniffer.

host name: www.myameego.com method: post path: /index2.php?do=login user agent: mozilla/5.0 (compatible; msie 10.0; windows nt 6.1; wow64; trident/6.0; np06) response code: 302 response string: found content type: text/html; charset=utf-8 referer: http://www.myameego.com/index.php?do=login transfer encoding: chunked server: apache content length: 17817 connection: keep-alive cache control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 location: /ameego/index.php cookie: x-mapping-fjhppofk=6a991610ba398b3a39f4b491d5382bb4; phpsessid=kbo25e08t3qvu08l1shkq8kk94; username=coled; pass=ed45d626b07112a8a501d9672f3b92796a6754b8d8d9cb4c617fec9774889220; clientid=129; x-mapping-fjhppofk=dce62fe972e1ef2f12d0060ec74c3681; phpsessid=ukeo21oldb5pqsntu7kl8j3b96 url: http://www.myameego.com/index2.php?do=login 

how can make packet 1 above? guidance appreciated.

i looked link posted , http sniffer shows post request being called cookie line doesn't match of manual browser request.

httpurlconnection httpconnection = (httpurlconnection)new url("http://www.myameego.com/index2.php?do=login").openconnection();     httpconnection.setdooutput(true);     httpconnection.setrequestmethod("post");     httpconnection.setrequestproperty("accept-charset","utf-8");     httpconnection.setrequestproperty("user-agent","mozilla/5.0 (compatible; msie 10.0; windows nt 6.1; wow64; trident/6.0; np06)");     httpconnection.setrequestproperty("content-type","application/x-www-form-urlencoded;charset=utf-8");     string info = string.format("user=%s&coled=%s",urlencoder.encode("user","utf-8"),urlencoder.encode("coled","utf-8"));     info += string.format("pass=%s&mypass=%s",urlencoder.encode("pass","utf-8"),urlencoder.encode("mypass","utf-8"));     info += string.format("clientid=%s&129=%s",urlencoder.encode("clientid","utf-8"),urlencoder.encode("129","utf-8"));     info += string.format("login=%s&sign in=%s",urlencoder.encode("login","utf-8"),urlencoder.encode("sign in","utf-8"));     httpconnection.setrequestproperty("cookie",info);     outputstream output = httpconnection.getoutputstream();     output.write(info.getbytes("utf-8"));     int x;     while((x = httpconnection.getinputstream().read()) != -1)system.out.print((char)x); 

my cookie: user=user&coled=coledpass=pass&mypass=mypassclientid=clientid&129=129login=login&sign in=sign+in

browsers cookie:
x-mapping-fjhppofk=6a991610ba398b3a39f4b491d5382bb4; phpsessid=112tg9i4afau5i382hui705553

anyone know may missing here?

with jsoup should simple this:

connection.response response = jsoup.connect("http://www.myameego.com/index2.php?do=login")         .method(connection.method.get)         .execute();  document page = jsoup.connect("http://www.myameego.com/index2.php?do=login")         .data("user", "login")         .data("pass", "password")         .data("clientid", "123456")         .cookies(response.cookies())         .post(); 

gathered google chrome developer tools

request

cookies used


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -