Re: Re: help curl followlocation

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

 



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/";);

On Wed, June 27, 2007 6:03 am, 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.
>
> Thanks in advance
>
> -gowranga
>
>
> --
> 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
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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