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

curl-and-php

Re: Not able to follow redirections

From: Gowranga <gowranga_at_serc.iisc.ernet.in>
Date: Thu, 5 Jul 2007 19:28:42 +0530 (IST)

>
> curl downloads the HTML exactly as the remote host (or proxy) provides it.
> If the links are all relative, you'll get them all relative.
>

Thanks for your mail. I used curl to download a form, and in order to get
authenticated on a remote site, tried the script:

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://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);
$result=str_replace('action="submit.htm"',
'action="https://remote.site.address/submit.htm"', $result);
curl_close($curl);
echo $result;
?>

I tried using POST method and pass credentials via POSTFIELD variables
but the remote site bailed me out, for, I guess the "action" was a
relative link. I therefore included str_replace statement to give control
to the absolute path of the action script at remote site. But now, I need
to know how I should post the revised information, before the session is
closed. Your help will be appreciated.

Thanks

-gowranga

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2007-07-05