Re: Getting result from URL
| From: | Stephen | Date: | Mon, 12 May 2003 23:45:04 +0000 |
| Subject: | Re: Getting result from URL | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-147370@lists.php.net to get a copy of this message | ||
No, I'm sending them using the GET method. Thank you so much! This script
might end up being published so what should I do incase a server is not
running 4.3.0?
Thanks,
Stephen Craton
http://www.melchior.us
----- Original Message -----
From: "John Coggeshall" <john@coggeshall.org>
To: "Stephen" <webmaster@melchior.us>
Cc: "PHP List" <php-general@lists.php.net>
Sent: Monday, May 12, 2003 6:29 PM
Subject: Re: [PHP] Getting result from URL
On Mon, 2003-05-12 at 19:22, Stephen wrote:
> I have a URL that if you send it parameters, it gives back a result in
plain text. What I want to do is dynamically send the parameters to the URL,
get the result back, and display certain information on the result.
You mean like a web service type of thing?
> My question is.. How would I get the result from the URL after sending it
the parameters?
If all you need to do is capture the data sent from a HTTP request, from
PHP 4.3.0 and up you can use streams with anything using a file
reference (like fopen, fread, fgets, etc)... hence:
$doc = "";
$fr = fopen("http://www.coggeshall.org/index.php?foo=1&bar=2",
'r');
while(!feof($fr)) {
$doc .= fread($fr, 1024);
}
fclose($fr);
If you need to pass parameters to the remote script via the POST method,
things are a bit more complex -- but that's basically the idea.
John
--
-~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~-
John Coggeshall
john at coggeshall dot org http://www.coggeshall.org/
-~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~-
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php