curl-and-php
Handling Meta-refresh with a unique,per-request URI
Date: Mon, 14 Jan 2008 11:11:13 -0000
Hi Everyone,
Hopefully someone will have experience and a solution to the following
problem.
I'm developing some internal tools here, and I need to login to a
third-party site that we use, and automatically download a report for each
of our clients. The report is in CSV format. My script used to work, but
since last week, the third-party has changed the way the csv files are
served.
Originally, my script successfully:
1) Logged into the site by POSTing the login details on the HTTPS site.
IT stored the session cookies in the cookieejar.
2) Followed the various redirects set by the login script
3) The script then GET the direct link to the specific csv file I was
interested in. Again, using HTTPS and session cookie. The csv file would
then be automatically downloaded.
However, it appears that the final step, the csv resource, now returns a 200
OK with a HTML page which contains a meta-refresh and javascript redirect,
which points to the csv file. Following the link"manually" with firefox
works correctly (as you would expect) but I am having real problems getting
the PHP cURL functions to do the same.
It appears that the link In the meta-refresh is unique for each the request.
It seems that once cURL retrieves the page, and I parse the HTML page using
Reg Exp to grab the URI, cURL must send a new request to follow the URI.
However, as the URI changes, as soon as cURL issuses the request, it is no
longer valid!
Can anyone provide any advice or a solution to this problem? Is it possible
to do some processing on the response before getting cURL to continue with
the original request? Would this be HTTP-pipelining in action? If so, is it
possible to perform HTTP-pipelining with cURL?
Any response would be appreciated!
Cheers,
Ben
Ben Davies | Lead Developer
Stickyeyes | Tel: 0113 391 2929 | Fax 0113 391 2939
SE_LOGO_SM
Stickyeyes is the trading name of Optimum4 Ltd
6th Floor, West One,
Wellington Street,
Leeds. LS1 1BA
This e-mail may contain information that is privileged, confidential or
otherwise protected from disclosure.
It must not be used by, or its contents copied or disclosed to persons other
than the intended recipient.
Any liability (in negligence or otherwise) arising from any third party
acting, or refraining from acting, on any
information contained in this e-mail is excluded. The views expressed may
not be official company policy,
but instead, the personal views of the originator.
If you have received this e-mail in error please notify the sender and
delete the e-mail.
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php