Jump to content


Photo

A question about curl and "CURLOPT_FOLLOWLOCATION"


  • Please log in to reply
3 replies to this topic

#1 cunoodle2

cunoodle2
  • Members
  • PipPipPip
  • Advanced Member
  • 602 posts

Posted 16 May 2006 - 10:08 PM

Ok.. so I have a curl script that auto logs me into my account at chase.com (I use it for tracking my IRA on a daily basis). They recently modified the login process and my script no longer works. Here is the only way to make it work...

Steps 1 and 2 of my code work PERFECT so far

1. Submit the form values to 'formpost.fcc'
I have NO idea what the source does for that page (something with a session and it just redirects me to..

2. sso_logon.jsp?fromLoc=ALL&LOB=COLLogon At this point I am still good.




Here is where my code stops working.
3. On the page mentioned about it has ANOTHER redirect to '/online/logon/on_successful_logon.jsp?LOB=COLLogon'

BUT it is redirecting the page to www.MY URL HERE.com/online/logon/on_successful_logon.jsp?LOB=COLLogon where I want it to redirect to www.chase.com/online/logon/on_successful_logon.jsp?LOB=COLLogon

Any ideas? I can provide the code in here upon request.

If the code was working and now it's not, something changed. Did you change any code?

yeah, just a little bit, I am trying to start from beginning and trace my steps to see what i did wrong unless you see it.


#2 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 16 May 2006 - 10:14 PM

Do you have at least these two options specified?

curl_setopt($c, CURLOPT_MAXREDIRS, 2);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);

[a href=\"http://us2.php.net/manual/en/function.curl-setopt.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.curl-setopt.php[/a]



#3 cunoodle2

cunoodle2
  • Members
  • PipPipPip
  • Advanced Member
  • 602 posts

Posted 17 May 2006 - 01:05 AM

toplay I am glad you hopped on here. I often have these "out of the norm" problems and you seem to be one of the few that has the answers. Unfortunatley this still does not work. Here is the code I am using now...

######### Prepare curl settings and variables #########
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, "https://chaseonline....s/formpost.fcc");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_MAXREDIRS, 2);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);

I actually noted that the code that is causing this problem is this which I can see on the 'view source' of the page...

function init()
{
processCookieOnSuccess();

<!-- document.on_succes_logon.action = "https://pfsonline.ch...welcome.jsp";-->

<!-- document.on_succes_logon.action = "sso_logoff_question.jsp";-->

document.on_succes_logon.action = '/colappmgr/colportal/customer?_nfpb=true&_pageLabel=page_myaccounts';
window.location.href='/colappmgr/colportal/customer?_nfpb=true&_pageLabel=page_myaccounts';
//document.on_succes_logon.submit();

//document.on_succes_logon.submit();
//document.location.href = document.on_succes_logon.action;
return true;
}

If the code was working and now it's not, something changed. Did you change any code?

yeah, just a little bit, I am trying to start from beginning and trace my steps to see what i did wrong unless you see it.


#4 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 17 May 2006 - 01:49 AM

You're missing this:

curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');

The cookie jar is good for the first request which sets the name of the file to store the cookie in. But on subsequent requests, you have to use the cookie file option and point it to the same cookie file so cURL reads the cookies from the file and sends them along with the HTTP request.

Specify both the cookie jar and cookie file at first since you have redirects. But if that doesn't work, then you may have to do it in steps. Like not follow redirects initially.

In case you're running this on a web host and not your local server, remember to save the cookie.txt in a private area (and not accessible to the public like the web folder).

While testing at first, it's probably good to increase CURLOPT_MAXREDIRS to more than 2 for now.

At the end, remember to delete (unlink) the cookie file.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users