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: Tue, 10 Jul 2007 17:15:36 +0530 (IST)

> You seem to be guessing blindly how to do this. Use LiveHTTPHeaders to
> record a manual "login", then use curl (with --trace-ascii) to work out
> the exact way to reproduce it (--trace-ascii of course used to verify
that > the protocol parts look similar enough to the the original manual
> approach) and then you translate it over to use PHP/CURL again (possibly
> curl --libcurl can help you do that faster).
>

Thanks for your mail. The outputs on using LiveHTTPHeaders to
record a manual "login", and that, when using curl with --trace-ascii are
identical in terms of the protocol applied by the remote site. I have
used the following translation in terms of PHP/CURL

<?php
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://address.remote.site");
curl_setopt($curl, CURLOPT_PROXY, "proxy:3128");
curl_setopt ($curl, CURLOPT_FRESH_CONNECT, true);
curl_setopt($curl, CURLOPT_COOKIE, 1);
curl_setopt($curl, CURLOPT_COOKIEFILE, "/tmp/cookie");
curl_setopt($curl, CURLOPT_COOKIEJAR, "/tmp/cookie");
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0);
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;
?>

I observe the cookies (with file permissions 777) get written too. However
when I furnish credentials, I get the error as "Pl enable cookies on your
browser" . On using -- header("Location: http://address.remote.site");--
my authentication gets through. Kindly let me know how I could emulate a
browser using /tmp/cookie.

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-10