Re: [PHP] a trivial little function (PostToHost)
At 12:27 PM -0600 10/4/09, kirk.john...@zootweb.com wrote: tedd tedd.sperl...@gmail.com wrote on 10/04/2009 08:51:13 AM: [PHP] 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 :) Hi Kirk: Okay, but what specifically is that script? I have written a script at server B to print_r($_POST), but I don't get anything other than log errors (see below*). Here's an example: http://www.webbytedd.com/aa/send-form/index.php You can enter anything into the webbytedd.com form (Server A) and click submit, but the php1.net form (Server B) won't show anything -- what am I doing wrong? Cheers, tedd * Log errors: [05-Oct-2009 15:08:54] PHP Warning: PHP Startup: mm_create(0, /session_mm_cgi-fcgi522) failed, err mm:core: failed to open semaphore file (Permission denied) in Unknown on line 0 -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] a trivial little function (PostToHost)
tedd tedd.sperl...@gmail.com wrote on 10/05/2009 01:44:00 PM: [snip] Hi Kirk: Okay, but what specifically is that script? I have written a script at server B to print_r($_POST), but I don't get anything other than log errors (see below*). Here's an example: http://www.webbytedd.com/aa/send-form/index.php You can enter anything into the webbytedd.com form (Server A) and click submit, but the php1.net form (Server B) won't show anything -- what am I doing wrong? Cheers, tedd * Log errors: [05-Oct-2009 15:08:54] PHP Warning: PHP Startup: mm_create(0, /session_mm_cgi-fcgi522) failed, err mm:core: failed to open semaphore file (Permission denied) in Unknown on line 0 I am not familiar with this PHP error. Was this on server B? With PHP Startup in the error message, it looks like a setup problem on server B, rather than being related to the PostToHost operation. Once that error is cleared up, start simple for the PostToHost piece. Just have the script on server B return hello,world!, then echo out that response in the script on server A. The PostToHost function you found is correct. Make sure you are passing in valid arguments, so that you end up with a valid HTTP POST message. Kirk
[PHP] a trivial little function (PostToHost)
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 -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] a trivial little function (PostToHost)
tedd tedd.sperl...@gmail.com wrote on 10/04/2009 08:51:13 AM: [PHP] 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