Re: a trivial little function (PostToHost)

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

 



tedd <tedd.sperling@xxxxxxxxx> wrote on 10/04/2009 08:51:13 AM:

>  a trivial little function (PostToHost)
> 
> tedd 
> 
> to:
> 
> php-general
> 
> 10/04/2009 09:05 AM
> 
> Hi gang:
> 
> The following 'trivial little' function I'm trying to get my head 
around:
> 
> http://aspn.activestate.com/ASPN/Mail/Message/php-general/1259426
> 
> The article states:
> 
> Either way, just generate your XML string and fire it at the remote
> machine.  You will need to write code to handle the response, obviously.
> 
> Okay, so how does one handle the response? I understand that one 
> should have the script at host A sending data to host B, but I can't 
> seem to get it to work. Does anyone have an example that works?
> 
> My confusion here -- is the data sent by the function at host A 
> accessible by host B via a POST, or does it write to a writable file, 
> or what?
> 
> Any help would be appreciated.
> 
> Cheers,
> 
> tedd

Yes, this is just a standard HTTP POST, just like what a browser does when 
you click a submit button. So, there needs to be a script that handles a 
standard POST on server B. It will send whatever response it is designed 
to. Just think of server A as a browser submitting a form and server B is 
you writing a PHP script to handle the form submission :)

Typically, I write the "fgets" line a little differently. Instead of:

while(!feof($fp)) {
        echo fgets($fp, 128);
}

I use:

$response = '';
while(!feof($fp)) {
        $response .= fgets($fp, 128);
}
// parse the response and do something

Kirk

[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