in reply to WWW::Mechanize login problems

@neverminda - Obviously I'm going to do more than just log on to my blogger account.

@naikonta - I was thinking about using the API, and I might have to if I don't solve this problem. Thanks for your input.

@moritz - That url string is taken from an iframe. If you just use $mech->get('http://www.blogger.com/'); you will find that google has hidden the login form in an iframe. I just took the url from that login and put it into a scalar variable.

The redirect is a javascript redirect. This is what it looks like (and where I've gotten stuck).
<html> <head> <script language="JavaScript" type="text/javascript"> <!-- function doRedirect(url) { open(url, "_top"); } --> </script> <script language="JavaScript1.4" type="text/javascript"> <!-- function doRedirect(url) { try { open(url, "_top"); } catch (xcp) { insertContinueLink(); } } --> </script> <script language="EcmaScript" type="text/javascript"> <!-- function doRedirect(url) { try { open(url, "_top"); } catch (xcp) { insertContinueLink(); } } --> </script> <script type="text/javascript"> <!-- var firsttime = "firsttime"; var goback = "goback"; var gofwd = "gofwd"; function redirect() { var url = 'https:\x2F\x2Fwww.google.com\x2Faccounts\x2FCheckCook +ie?service=blogger&chtml=LoginDoneHtml'; var state = document.dummyform.dummyfield.value; var lastUrl = document.dummyform.dummyfield2.value; if ((state == firsttime) || (url != lastUrl)) { // First time visit or passive login document.dummyform.dummyfield.value = goback; document.dummyform.dummyfield.defaultvalue = goback; document.dummyform.dummyfield2.value = url; document.dummyform.dummyfield2.defaultvalue = url; doRedirect(url); } else if (state == goback) { // Remember that we should go forward next time and go backwar +d. document.dummyform.dummyfield.value = gofwd; document.dummyform.dummyfield.defaultvalue = gofwd; history.back(); } else if (state == gofwd) { // Remember that we should go backward next time and go forwar +d. document.dummyform.dummyfield.value = goback; document.dummyform.dummyfield.defaultvalue = goback; history.forward(); } } // Tells the user we are waiting for the page to redirect function insertLoadingMessage() { document.getElementById("loadingDiv").style.visibility = "visibl +e"; } function insertContinueLink() { document.getElementById("loadingDiv").style.visibility = "hidden +"; document.getElementById("clickToContinue").style.visibility = "v +isible"; } --> </script> <style type="text/css"><!-- body { color:white; background:#F5EDE3; font-size: 12; font-family:"Trebuchet MS"; } #loadingDiv { float:left; background:#826C55; margin:10px 0 0 10px; } a { color: white; } --></style> <script type="text/javascript"><!-- if (document.referrer.indexOf('nui=8') >= 0) { document.write('<style type="text/css">'); document.write('#body { background: #036 }'); document.write('#body #loadingDiv { background: none }'); document.write('</style>'); } // --> </script> </head> <body onload="insertLoadingMessage();redirect();" id="body" dir="ltr" onpageshow="if (event.persisted) redirect();"> <div id="loadingDiv" style="visibility:hidden;"> Loading... </div> <div style="visibility:hidden;" id="clickToContinue"> <a target="_top" href="https://www.google.com/accounts/CheckCookie?s +ervice=blogger&chtml=LoginDoneHtml">Click here to continue</a> </div> <form name="dummyform" action="" > <input name="dummyfield" value="firsttime" style="visibility:hidden" + /> <input name="dummyfield2" value="" style="visibility:hidden" /> </form> <noscript> Please <a href="https://www.google.com/accounts/CheckCookie?service=blogger +&chtml=LoginDoneHtml" target="_top">click here to continue</a>. </noscript> </body> </html>

I've tried to do a $mech->follow_link( text => 'click here to continue'); but that just takes you in a circle.

I also tried using a regular expression to take out "https:\x2F\x2Fwww.google.com\x2Faccounts\x2FCheckCook +ie?service=blogger&chtml=LoginDoneHtml" (the redirect url), but I get a "500 Can't connect to :443 (Bad hostname '')" error.

Replies are listed 'Best First'.
Re^2: WWW::Mechanize login problems
by naikonta (Curate) on May 29, 2007 at 04:11 UTC
    I was thinking about using the API, and I might have to if I don't solve this problem.
    The problem is, reverse engineering tasks are so tedious, and tricky. They provide API so people can develop cleaner way to access their web services. But, well, all the tools are in your hand :-)
    https:\x2F\x2Fwww.google.com\x2Faccounts\x2FCheckCook +ie?service=blogger&chtml=LoginDoneHtml
    I think the \x2F is the way JavaScript encodes normal slash (/). If I rewrite it like:
    https://www.google.com/accounts/CheckCookie?service=blogger&chtml=Logi +nDoneHtml
    I get a response that says: Your browser's cookie functionality is turned off. Please turn it on. If I'm currently logged in to one of the services, the response I get is my account page. I think you're halfway there.

    Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!