Extracting XML MO (Mobile Originated) POST data using PHP

A service provider is giving me a headache. The support guys are not really helping so I am going to post here. I have the following code.

<?php

require_once '../config/database.php';

// read raw POST data
$postData = file_get_contents("php://input");
// extract XML structure from it using PHP’s DOMDocument Document Object Model parser
$dom = new DOMDocument();
$dom->loadXML($postData);
// create new XPath object for quering XML elements (nodes)
$xPath = new domxpath($dom);
// query “message” element
$reports = $xPath->query("/data/record");
// write out attributes of each “message” element
foreach ($reports as $node) {
    $id = $node->getAttribute('id');
    $status = $node->getAttribute('text');
    $updateSMS= mysql_query("UPDATE sms SET message = '{$text}' WHERE ref_no='{$id}'");
}
?>

and here is the MO (Mobile Originated) XML that is being posted (to the file with the code above) according to the services provider. is like so:

POST http://yoururl.com/2way/receiver.php <data> <record> <binary>454C494D5520746573743233333274657374</binary><text>ELIMU test2332test</text><esmClass>0</esmClass><dataCoding>0</dataCoding><receiver>44786XXXXXX </receiver><channelId>JJJJJJ</channelId><keyword></keyword><id>8344551813527196894</id><sender>3859XXXXXX</sender><timestamp>2014-02-21 10:06:34</timestamp><cleanText>ELIMU test2332test</cleanText><pairedMessageId></pairedMessageId><smsCount>1</smsCount></record> </data> 

unfortunately, the code above is not working at all. The only help they are providing is the sample MO XML POST example above. Any Ideas?

728x90

0 Answers Extracting XML MO (Mobile Originated) POST data using PHP