Re: help curl followlocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

Thanks for your mail. However, I am not clear on how to use curl for my
purpose. Kindly help me. In order to authenticate myself on a remote
server,
I have tried the following two ways:

Method I
<?php
header("Location: http://remote.site.address";);
?>

On the resulting html page containing a form, I am able to pass credential
details and get through.


Method II
I try the script

<?php
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://remote.site.address";);
curl_setopt($curl, CURLOPT_PROXY, "proxy:port");
curl_setopt($curl, CURLOPT_FRESH_CONNECT, true);
curl_setopt($curl, CURLOPT_COOKIEFILE, "/tmp/cookie");
curl_setopt($curl, CURLOPT_COOKIEJAR, "/tmp/cookie");
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 40);
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Pragma: "));
$result=curl_exec($curl);
curl_close($curl);
echo $result;
?>

The permissions set on /tmp/cookie file are 0757. However, when I furnish
credential details, I get error as "Please enable cookies on your
browser".
Kindly help me understand how to set these cookies.

Thanks

-gowranga


> When your PHP script does "curl" it does not interact in any way,
> shape, or form with the Location bar of the browser...
>
> That's kinda the whole POINT of curl, to be able to snarf down content
> from inside your script, instead of pushing the user off to some other
> site.
>
> If you just want to send the user off to Google's site, you can skip
> curl and use:
> header("Location: http://google.com/";);



-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux