cURL: can't prevent url redirect

This is a discussion on cURL: can't prevent url redirect within the PHP General forums, part of the PHP Programming Forums category; This login script works when I use Snoopy (php http class), but here with php curl the response is the ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-30-2006
Andrew Warner
 
Posts: n/a
Default cURL: can't prevent url redirect

This login script works when I use Snoopy (php http class), but here
with php curl the response is the redirected page. The script is
following a 302 redirect and I don't want it to because I need some
header info from the 302 page. The curl_setopt($ch,
CURLOPT_MAXREDIRS, 0); doesn't seem to be preventing redirect:



$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_MAXREDIRS, 0);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);

curl_setopt($ch, CURLOPT_REFERER, $url_ref);
curl_setopt($ch, CURLOPT_HTTPHEADER, $the_headers);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_str);

$response = curl_exec($ch);
curl_close($ch);


drew



Reply With Quote
  #2 (permalink)  
Old 11-30-2006
Richard Lynch
 
Posts: n/a
Default Re: [PHP] cURL: can't prevent url redirect

On Wed, November 29, 2006 10:09 pm, Andrew Warner wrote:
> This login script works when I use Snoopy (php http class), but here
> with php curl the response is the redirected page. The script is
> following a 302 redirect and I don't want it to because I need some
> header info from the 302 page. The curl_setopt($ch,
> CURLOPT_MAXREDIRS, 0); doesn't seem to be preventing redirect:
>
>
>
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_URL, $url);
>
> curl_setopt($ch, CURLOPT_MAXREDIRS, 0);
> //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);


Put that line back in there, and parse the headers for yourself, and
do the 302 in another curl request.

I *think* that should work...

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:28 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0