Re: Getting result from URL
| From: | John Coggeshall | Date: | Mon, 12 May 2003 23:29:15 +0000 |
| Subject: | Re: Getting result from URL | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-147369@lists.php.net to get a copy of this message | ||
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/
-~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~-