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: Wed, 13 Jun 2007 19:14:27 +0530 (IST)

Hello,

My installation details are:

curl 7.16.2 (i686-pc-linux-gnu) libcurl/7.16.2 OpenSSL/0.9.7a zlib/1.2.1.2
libidn/0.5.6
Protocols: tftp ftp telnet dict ldap http file https ftps
Features: IDN Largefile NTLM SSL libz

I have tried to use the following standard examples to reach sites like
Amazon and Google. While I do get the relevant pages on the browser, the
URL
doesn't seem to change to the remote site. I have tried using different
User agents, but followlocation seems to be not working. Kindly let me
know if libcurl has not been compiled properly because curl on command
line too
fails. Attempts to use curl_easy_setopt gives error such as function is
not defined.

<?php

//$url =
"http://www.amazon.com/exec/obidos/search-handle-form/002-5640957-2809605";
$url = "http://www.google.com";
$ch = curl_init();
// initialize curl handle
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_PROXY, "proxy_server:port");
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
//curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT
5.1; en-US; rv:1.7.13) Gecko/20060414");
//curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4");
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
$result = curl_exec($ch); // run the whole process

curl_close($ch);
echo $result;
?>

Thanks in advance

-gowranga

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2007-06-13