Re: Strange results from file_get_contents using an url as filename

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

 



On Tuesday 28 December 2004 20:03, Ewout de Boer wrote:

>   $data =
> file_get_contents("http://somehost.com/xmlonl.asp?custid=000000&prodid=0000
>0 ");
>
>   if ($data)
>   {
>     ...
>
>
> the string this function returns is the webpage from the default website of
> the server where this php code is running at and not the data from the
> remote site (which is not on the same server).

Have you tried other URLs? With and without a query string? Could you give a 
_real life_ example of a URL that doesn't work?

> i tried the url from my shell on the server using telnet and it gets the
> data i expected.
>
> I can't figure out why php is getting the wrong results while telnet on the
> same host gets the correct data. Is this a (known) error with php or is it
> a apache/php/server configuration problem ?

One possible explanation as to why it doesn't work within PHP but works with 
something else is that the target site looks at the user-agent in the request 
header and if it finds something it doesn't like (eg PHP) then it redirects 
the request to http://localhost/ or something. That way the target site hopes 
to prevent bots from harvesting its data. 

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
I didn't want a hokey second wedding like those ones on TV!  This one's
for real!

  -- Homer Simpson
     A Milhouse Divided
*/

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