cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: Curl with PHP Following Redirects and Forwarding Everything..

From: Morgan Galpin <morgan_at_atsourceinc.ca>
Date: Mon, 10 Dec 2007 09:41:33 -0800

Try using:
     |curl_setopt($ch, ||CURLOPT_FOLLOWLOCATION||, true);
|
If that doesn't work, there is a function listed in a comment by "eion
at bigfoot dot com" at
http://www.php.net/manual/en/function.curl-setopt.php . It seems to have
some merit though I haven't tried it out. If that doesn't work out for
you, there are lots of other redirect related comments on that page.

There are different ways to accomplish a redirect on a web page. It
looks like the code that I've referenced above looks for a "Location:"
header. I don't think it handles meta refreshes however.

To handle cookies, try:
     |curl_setopt($ch, ||CURLOPT_COOKIEFILE||, 'C:/path/to/cookie.file');
| |curl_setopt($ch, ||CURLOPT_COOKIEJAR||,
||'C:/path/to/cookie.file'||);|
||
to have curl keep track of cookies.

That should get you started.
Good luck,
Morgan Galpin.

lucas fambrough wrote:
> Hi guys and girls,
>
> New here, but have a challenging question(at least to
> me). I'm working with a a third party who has a
> webpage. This particular webpage may or may not have
> a redirect to other pages that may or may not have
> redirects. Regardless of the number of redirects I
> need to do the following with php.
>
> 1. hit that initial web page and if it has a redirect
> follow the redirects recursively to the end.
> 2. collect all the cookies from the initial page and
> pass them through to each redirect, grabbing all the
> cookies along the way (if there are further redirects)
> and passing them along to the final destination page.
> 3. this script needs to finally disply the webpage of
> the final desination page.
> 4. the script has to be able to support multiple
> sessions (there could be more than one person hittin
> the script at once).
>
> i know this is alot, but someone must have run into
> this before. i need a bit of hand holding on this
> cause i'm relatively new to curl, but i'm willing to
> pay $20 bucks to the person who finally solves this
> for me via paypal.
>
> thanks!
>
>
> The ability to focus attention on important things is a
> defining characteristic of intelligence. (Robert J. Shiller)
>
>
>
> ____________________________________________________________________________________
> Never miss a thing. Make Yahoo your home page.
> http://www.yahoo.com/r/hs
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2007-12-10