On Wed, 2007-06-27 at 16:33 +0530, Gowranga wrote: > Hello, > > I have the following installed on a Redhat ES4 system: > > curl 7.12.1 (i686-redhat-linux-gnu) libcurl/7.12.1 OpenSSL/0.9.7a > zlib/1.2.1.2 libidn/0.5.6 > Protocols: ftp gopher telnet dict ldap http file https ftps > Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz > > Server version: Apache/2.0.59, PHP 5.2.3 (cli) > > I'm trying to use the curl library to request a google search page. The > page is requested fine, however, the url that is shown in the browser is > the url of the page that is making the request and not the google page. > Without the FOLLOWLOCATION curl option, I do get a 302 http code and curl > in command mode too gives the same result. > > The script used is > > <?php > $curl = curl_init(); > curl_setopt($curl, CURLOPT_URL, "http://www.google.com"); > curl_setopt($curl, CURLOPT_PROXY, "proxy:port"); > curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); > curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); > curl_setopt($curl, CURLOPT_TIMEOUT, 40); > curl_setopt($curl, CURLOPT_COOKIEFILE, "/tmp/cookie"); > curl_setopt($curl, CURLOPT_COOKIEJAR, "/tmp/cookie"); > curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); > curl_setopt($curl, CURLOPT_AUTOREFERER, 1); > curl_setopt($curl, CURLOPT_REFERER, "http://www.google.com"); > curl_setopt($curl, CURLOPT_HEADER, 1); > curl_setopt($curl, CURLOPT_VERBOSE, 1); > curl_setopt($curl, CURLOPT_HTTPHEADER, array("Pragma: ")); > preg_match_all('|Set-Cookie: (.*);|U', $content, $result); > $cookies = implode(';', $result[1]); > curl_setopt($curl, CURLOPT_COOKIE, $cookies); > $content=curl_exec($curl); > echo $content; > curl_close($curl); > ?> > > I have tried with higher versions of openssl, zlib and curl but get > nothing better. I am able to retrieve Location information by using > preg_match on the output headers, but I am keen in using FOLLOWLOCATION. > Kindly suggest some workaround. >From the PHP docs: CURLOPT_FOLLOWLOCATION (integer) This constant is not available when opendbase_dir or safe_mode are enabled. Do you have openbase_dir or safe_mode on? Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php