FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » cURL and response code 302
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: cURL and response code 302 [message #182108 is a reply to message #182101] Wed, 10 July 2013 15:09 Go to previous messageGo to previous message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma:
Senior Member
On 7/9/2013 11:20 AM, Arno Welzel wrote:
> Am 09.07.2013 16:51, schrieb bill:
>> On 7/9/2013 10:24 AM, Arno Welzel wrote:
>>> Am 09.07.2013 16:09, schrieb bill:
>>>
>>>> On 7/8/2013 12:02 PM, Daniel Pitts wrote:
>>>> > On 7/8/13 8:35 AM, bill wrote:
>>>> >> when I have cUrl seet up with CURLOPT_FOLLOWLOCATION =>FALSE,
>>>> >> I am getting a 302, moved temporarily.
>>>> >>
>>>> >> How do I find out the URL it is being redirected to ?
>>>> >> The effectiveURL that is returned is the one I sent the request
>>>> >> to.
>>>> >>
>>>> >> bill
>>>> >
>>>> > The "Location" response header contains the desired URL.
>>>> >
>>>> > See:
>>>> > <http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3>
>>>>
>>>> Thanks, is there a way to obtain the Location response header
>>>> from cURL ?
>>>
>>> Maybe this example in the documentation may help:
>>>
>>> <http://www.php.net/manual/en/function.curl-exec.php#80442>
>>>
>>>
>>>
>> actually, suggesting that I look at curlopt_header would have
>> been more clear.
>
> Maybe - but since it is also neccessary to check the header size to
> separate the header from the body I refered to the example. And finally
> you got the right hint - didn't you? ;-)

using:

function curl_getNoFollow($url, array $get = NULL, array $options
= array() ){
$defaults = array(
CURLOPT_HEADER => 0,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_FORBID_REUSE => 1,
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYPEER =>0,
CURLOPT_COOKIEFILE => '/tmp/cookies.txt',
CURLOPT_COOKIEJAR=> '/tmp/cookies.txt',
CURLOPT_HEADER =>TRUE,
CURLINFO_HEADER_OUT => TRUE,
CURLOPT_FOLLOWLOCATION =>FALSE,
CURLOPT_USERAGENT =>'Mosilla/5.0(Windows NT 6.1,;WOW64,rv21.0)
Gecko/20100101 Firefox/21.0)',
);
$ch = curl_init();
curl_setopt ($ch,CURLOPT_URL, $url);
curl_setopt_array($ch, ($options + $defaults));

$result = curl_exec($ch);

$eurl = curl_getinfo($ch,CURLINFO_EFFECTIVE_URL);
$http =curl_getinfo($ch,CURLINFO_HTTP_CODE);

$resultx =array($result, $eurl, $http,); // result is an
array($result, $eurl, $http)
curl_close($ch);

return $resultx;
}

I get:
url: http://www.mydomain.com/login/login.cfm, http: 302

note the lack of information about the refer to address, which I
need so I can follow.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Install Apache Php Windows 64 bit
Next Topic: Heartbleed bug?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 14:09:19 GMT 2024

Total time taken to generate the page: 0.04338 seconds