Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

cXML Post & Parse - PHP

Question about cXML Post and Parse

4:58 pm on Oct 27, 2009 (gmt 0)

New User

5+ Year Member

joined:Oct 27, 2009
votes: 0

I am trying to make my ecommerce site work effectively with a buyer that requires a 3rd party procurement system.

They have told me that they are posting the data using the following method:

$fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
if (!$fp)
echo 'Could not open connection.';
$xmlpacket ='<?xml version="1.0"?>
$contentlength = strlen($xmlpacket);
$out = "post /script_name.php HTTP/1.0\r\n";
$out .= "Host: www.example.com\r\n";
$out .= "Connection: Keep-Alive\r\n";
$out .= "Content-type: application/x-www-form-urlencoded\r\n";
$out .= "Content-length: $contentlength\r\n\r\n";
$out .= "xml=$xmlpacket";
fwrite($fp, $out);
while (!feof($fp))
$theOutput .= fgets($fp, 128);
// $theOutput is the response returned from the remote script

When they run tests, or when I run tests (both with valid XML, not just the empty XML in the example), I end up with nothing but an empty array when I echo $_POST.

Does anyone have any insight on what the problems might be here? Is there any other way that I could be receiving and access this information other than inside the $_POST variable?

10:33 pm on Oct 27, 2009 (gmt 0)

Senior Member from CA 

WebmasterWorld Senior Member httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 29, 2003
votes: 0

Welcome to WebmasterWorld, cocorocks!

I'm going to move this one into the PHP forum, OK?

4:20 pm on Oct 28, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 30, 2003
votes: 0

Hi cocorocks, welcome to WebmasterWorld. :)

When you check the post array you need to use print_r. Is that how you were doing it and echo was a typo?

echo '<pre>';
echo '</pre>';

If you are just echoing $_POST you will see 'Array' and nothing more.