rmccallum
rmccallum

Reputation: 214

Process cXML POST data in PHP

Building a punchout system and the data supplied by POST is cXML. What is the best way to process through the cXML data?

I am trying to pull out certain values (username, password etc) and am generating an XML file to return to the supplier.

I have the second part done but it's the handling of the POST that has me stuck. I have been banging my head trying to get $_POST to convert the data back into cXML.

Once I have the data in I can process it:

$senderIdentity = $xml->Header->Sender->Credential->Identity;
$senderSharedSecret = $xml->Header->Sender->Credential->SharedSecret;
$buyerCookie = $xml->Request->PunchOutSetupRequest->BuyerCookie;
$requestURL = $xml->Request->PunchOutSetupRequest->BrowserFormPost->URL;
$payloadID = $xml->attributes()->payloadID;

It's just the initial pull in that I can't get correct.

Eventually this will be put onto a HTTPS if that has any influence.

Any help would be appreciated.

regards, Robert

Upvotes: 1

Views: 4102

Answers (1)

rmccallum
rmccallum

Reputation: 214

I got this sorted using:

file_get_contents('php://input')

And then using simplexml_load_string based on the input received.

Upvotes: 1

Related Questions