Reading text file via http

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I need to read some data from a web service using JSON.

I thought I could read text from a URL like so:

$handle = fopen(" ", "r");
$contents = stream_get_contents($handle);

echo $contents;

But after 30 seconds that times out with the following error:
"Warning: fopen( ) [function.fopen]: failed
to open stream: A connection attempt failed because the connected
party did not properly respond after a period of time, or established
connection failed because connected host has failed to respond."

Am I doing something wrong? Or is there something else I need to


Re: Reading text file via http

Quoted text here. Click to load it

Code looks OK - should work.

Have you tried accessing the URL via a different method e.g. wget from
command line (to ensure no firewall / DNS / network issues) ?


Site Timeline