• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Exporting AOL addressbook..

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,
I am kinda newbie in programming. I wonder anyone of you have worked on exporting AOL addressbook from a java program through httpclient. I am facing a problem as after logging successfully when i try to open the addressbook URL , it is redirecting me back to login page asking again for password. It should have given me the html of address book page as a result but it is giving the following response string.
<html><body><script>var targetURL = 'http://my.screenname.aol.com/_cqr/login/login.psp?seamless=novl
&sitedomain=sns.webmail.aol.com&lang=en&locale=us&authLev=2
&siteState=ver%3a1%252c0%26ld%3am01.webmail.aol.com%26rp%3aab%252f
addresslist.aspx%253fsitedomain%253dsns.webmail.aol.com%2526
authLev%253d2%2526siteState%253dver%25253a1%2525252c0%252526ld%25253
awebmail.aol.com%252526pv%25253aAOL%252526lc%25253aen-us%2526lang%253
den%2526locale%253dus%2526mcAuth%253d
%25252fBcAG0OW31wAAPd7AJ%25252fp5kOW35gImND%25252fNKplmT4AAA%25253d%25253d%26 pv%3aAIM%26lc%3aen-us';

function FindMainWindow() {
for (var w = window; true; w = w.parent) {
if (w.GetMainWindow)
return w.GetMainWindow();
if (w.parent == w)
break;
}

for (w = opener; w != null && !w.closed; w = w.opener)
if (w.GetMainWindow)
return w.GetMainWindow();

return null;
}

var mw = FindMainWindow();
if (mw && !mw.closed)
mw.top.location = targetURL;
else {
var w = window.open(targetURL, '', '', true);
if ((w == null) && (window == top)) window.location = targetURL;
}
</script></body></html>

Can anyone here help me out. I desperately need a solution.
Regards,
Priyanshu

[ Edited by Ulf Dittmer: broke down the URL into several lines to make it readable ]
[ December 09, 2005: Message edited by: Ulf Dittmer ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're getting the login page again, I'd say that the login doesn't work. Instead of HttpClient, I'd use HtttpUnit instead, which make sit easier to work with the HTML you're receiving.
Either way, it's not about a SUn API, so I'm moving this to Other Open Source Projects.
 
priyanshu dubey
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ulf,
million thanks for ur reply
I also figured out that actually login isn't working. But can you suggest some way out. I did it successfully with hotmail and gmail. Something seems to be missing in my AOL login form.
Waiting for ur reply
Priyanshu
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the login doesn't work, you may have omitted some parameter that's required. I would use a tool like LiveHTTPHeaders (a Firefox extension) to observe which parameters are sent if you connect via a browser. Then you can duplicate all those in your Java application.

By the way, welcome to JavaRanch!
 
priyanshu dubey
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ya thanks dear....i am just a fresh graduate and it was my very first post on javaranch....hope to have a long journey with u and javaranch.
btw if i give u the code, can u make a quick glance and share some expert view if only u hv a little time to spare.
Regards,
Priyanshu
 
priyanshu dubey
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok gr8...i will use this liveHTTPheaders.
thnx again
Priyanshu
 
priyanshu dubey
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ulf,
i copied all the headers and still i am getting login page html as result string when i am using post method. (
Priyanshu
 
priyanshu dubey
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello ulf,
i did all with livehttp headers. There is a cookie named auth which is set after authentication. How can i get this cookie? I am using client.getstate().getkookies() but it is not giving me this cookie. Suggest something my friend.
Regards,
Priyanshu
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HttpClient can deal with cookies in general, but I'm not familiar with it. Your best bet may be to study the documentation, and try to understand how to use cookies with HttpClient.
 
priyanshu dubey
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ulf,
i tried url rewriting and added jsessionid with my desired url. Now in my response i am getting some hexadecimal coding or whatever it is.

Now can u tell if it can be converted back to some string form or something?
Regards,
Priyanshu
 
priyanshu dubey
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is ir something in binary?
 
priyanshu dubey
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ulf,
the thing is i am getting jsessionid cookie after posting the form. how is it possible that i am getting the session when i am not logged in?
Regards,
Priyanshu
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The session is independent of whether or not you are logged in. That you get a session cookie (or a jsessionid in the URL) does not mean that you are logged in, merely that the server has opened a session for you.
 
priyanshu dubey
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
NameValuePair[] data = {
new NameValuePair("sitedomain", "sns.webmail.aol.com"),
new NameValuePair("siteId", ""),
new NameValuePair("lang", "en"),
new NameValuePair("locale", "us"),
new NameValuePair("authLev", "2"),
new NameValuePair("siteState", "ver%253A1%25252c0%2526ld%253Awebmail.aol.com%2526pv%253AAOL%2526lc%253Aen-us"),
new NameValuePair("isSiteStateEncoded", "true"),
new NameValuePair("mcState", "initialized"),
new NameValuePair("usrd", "9633915"),
new NameValuePair("loginId", login),
new NameValuePair("password", password),
new NameValuePair("rememberMe", "off")
};

post.addRequestHeader("Accept","text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5");
post.addRequestHeader("Accept-Language","en-us,en;q=0.5");
post.addRequestHeader("Accept-Encoding","gzip,deflate");
post.addRequestHeader("Accept-Charset","ISO-8859-1,utf-8;q=0.7,*;q=0.7");
post.addRequestHeader("Keep-Alive","300");
post.addRequestHeader("Connection","keep-alive");
post.addRequestHeader("Referer","https://my.screenname.aol.com/_cqr/login/login.psp?mcState=initialized
&seamless=novl&sitedomain=sns.webmail.aol.com&lang=en&locale=us&authLev=2&siteState=ver%3a1%252c0%26ld%3a
webmail.aol.com%26pv%3aAOL%26lc%3aen-us");
post.addRequestHeader("Cookie","SNS_LDC=1 sns.webmail.aol.com 1 1134247948 0 1134246434 0; RSP_COOKIE=type=1&name=cHJpeWFuc2h1aHA%3D; SNS_TT=AAtwcml5YW5zaHVocEObOiIAABAAAQA8dqFQJMliXmTY4i0Mc1q7yzvM1a3QIlKa3KgAOIaYHHVNwiYsLILz8ukZGqVyLyotMDJU4mRWX6VS69be; s_cc=true; s_sq=aolcommem%2Caolsvc%3D%2526pid%253Dacp%252520%25253A%252520AOL.com
%252520Main%2526pidt%253D1%2526oid%253Dhttp%25253A//webmail.aol.com/%2526
ot%253DA%26aolaimmail%3D%2526pid%253Dwml%252520%25253A%252520MessageList%252520
Content%2526pidt%253D1%2526oid%253Dhttp%25253A//m01.webmail.aol.com/15106/aim/en-us/Shared/Logout.aspx%2526ot%253DA; SNS_DIS_WSC=1; SNS_DIS_AIM=1; SNS_SC=diAxLjAga2lkIDEgcFRnS21ST1hFaGdzSEFUWlVucFYxbWJBUllNPQ%3D%3D
-xwt4pvwxgiOV%2FMJCGA%2BBzokOINp5237LltqV1fiqJbW0cHDNUpxFXrXavYQKdcSZbb%2B
uHjLfBYQUBq0U%2Fmr1DUhPomsC2bhr3TRPlnbxXrf%2BrfHad2UlqA%3D%3D");
post.addRequestHeader("Content-Length","266");
post.addRequestHeader("Content-Type", "application/x-www-form-urlencoded");
post.addRequestHeader("User-Agent","Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041215 Firefox/1.0 Red Hat/1.0-12.EL4");
post.setRequestBody(data);
post.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);

log.info("Request Body: " + post.toString());

statusCode = -1;
try {
// execute the method.
statusCode = client.executeMethod(post);
System.out.println(statusCode);
}catch (IOException e) {
log.error("Failed to open url.");
return HTTP_REQUEST_FAILURE;
}

hey ulf, can u check it...what is the problem in it.Why i am not able to login from this code? I have added all the headers and parameters. You've helped me a lot, if anything more u can do, plz do it.
Regards,
Priyanshu

[ Edited by UD to shorten the lines that were messing up the formatting ]
[ December 12, 2005: Message edited by: Ulf Dittmer ]
 
Sometimes you feel like a nut. Sometimes you feel like a tiny ad.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic