|
Posted by -Lost on 06/20/06 04:13
Assuming you are using a redirect via the location header, you could try:
<?php
$_ch = curl_init();
$url = 'http://toe/tmp/curl_redirect.php';
/*
// set the URL
// we want the output, we do not want it output
// follow all "Location: " headers
// avoid getting caught in a loop somewhere
*/
curl_setopt($_ch, CURLOPT_URL, $url);
curl_setopt($_ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($_ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($_ch, CURLOPT_MAXREDIRS, 1); // google.com requires 2
/*
// execute the current CURL session/handler
*/
$_ch_output = curl_exec($_ch);
/*
// where are we now? (302)
*/
print curl_getinfo($_ch, CURLINFO_EFFECTIVE_URL);
curl_close($_ch);
?>
In, curl_redirect.php I put:
<?php
header('Location: http://google.com/');
?>
So, you should see:
http://google.com (first redirect from Location: header)
Change CURLOPT_MAXREDIRS to 2 (where I noted) to see the redirect from http://google.com
to http://www.google.com/.
Hope this helps.
-Lost
Navigation:
[Reply to this message]
|