• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Application using webpages for profile changes  RSS feed

R Johnson
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am attempting to create an application that logs into a site (I provide my code for yahoo because javaranch does not seem to support GET method in their login) I'm using the overridden CookieManager I found here http://www.hccp.org/java-net-cookie-how-to.html. I tried here http://java.sun.com/docs/books/tutorial/networking/cookies/cookiemanager.html and I've spent the day looking at forums and similiar types for maybe a clue as to what I need to do. I altered the main of the program found at the bottom of this site http://www.hccp.org/java-net-cookie-how-to.html to look like this

This appears to allow me to login to yahoo but the returned html code is one saying the browser could not redirect which I understood because it's not a browser. So i tried to create another URLConnection and just cm.setCookies(conn2=url2.openConnection()); then returned the code of conn2 where url2 was set for http://my.yahoo.com. It returned the my yahoo page but not as me , but as a new user who needed to login. Then I tried to get the cookies on this new connection and resubmit with the extened cookies again to my.yahoo.com where I did get many more cookies I was still not logged in as a user.
My first cookies looked like this:

{yahoo.com={B={ expires=Tue, 16-Jan-2012 20:00:00 GMT, domain=.yahoo.com, B=fasdfashgh&b=73&s=unb, path=/}}}

My Second cookies looked like this

{yahoo.com={B={ expires=Tue, 16-Jan-2012 20:00:00 GMT, domain=.yahoo.com, B=fasdfasda&b=73&s=unb, path=/}, U_mtupes={ expires=Thu, 15-Jan-2009 19:55:22 GMT, domain=my.yahoo.com, U_mtupes=deleted, path=/}, MYTMI={ expires=Sat, 15-Jan-2011 19:55:22 GMT, domain=my.yahoo.com, path=/, MYTMI=546}, myc_s={ domain=my.yahoo.com, path=/, myc_s=d=aghafhhdshsghshsh.gfdgsgsdfgsdgs… myc={ expires=Sat, 15-Jan-2011 19:55:22 GMT, domain=my.yahoo.com, path=/, myc=d=fdasfdsafasdfdsafsa_afdasfasdfsda_&tv=unb, path=/}}}
I did change the cookies but tried to keep any formating symbols like periods and _ underscores and amperstands &... Just hoping maybe someone can tell me how to get the my.yahoo.com page through a java app.

There may be an easier way using just the original java.net.CookieManager but I tried looking at Sun api and that tutorial above and it doesn't explain in full detail how to even initiate the Manager(Store,PolicY) I can get CookieManager(null,CookiePolicy.ANY) to work but I'm pretty sure I need the store in there not to be null. Any help would be greatly appreciated
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!