Hi;
I am a newbie in developing an SMS Based system particularly in the use of php nusoap libraries. Right now i am having difficulty achieving success in testing my SMS system. What i am trying to do was that i want to register as a user using SMS by texting REG NAME AGE LOCALCHURCH DISTRICT and send to 23730731 my access code. Here’s what i did:
Register.php
<?php
// This will allow user to register via SMS.
error_reporting(0);
// load the nusoap libraries. These are slower than those built in PHP5 but don't require you to recompile PHP
include_once('nusoap.php');
// create the client and define the URL endpoint
$client = new nusoap_client('http://iplaypen.globelabs.com.ph:1881/axis2/services/Platform/');
// set the character encoding, utf-8 is the standard.
$client->soap_defencoding = 'UTF-8';
$client->call('sendSMS', array( 'uName' => '48dwi5',
'uPin' => '159597',
'MSISDN' => '09152886810',
'messageString' => 'Registered Successfully',
'Display' => '1',
'udh' => '',
'mwi' => '',
'coding' => '0' ),
"http://ESCPlatform/xsd");
?>
Here is also the xml format of texting SMS via 23730731.
<?xml version="1.0" encoding="utf-8"?>
<message>
<param>
<name>id</name>
<value>2373094420110106170141</value>
</param>
<param>
<name>messageType</name>
<value>SMS</value>
</param>
<param>
<name>target</name>
<value>23730731</value>
</param>
<param>
<name>source</name>
<value>09152886810</value>
</param>
<param>
<name>msg</name>
<value>REG</value>
</param>
<param>
<name>msg</name>
<value>NAME</value>
</param>
<param>
<name>msg</name>
<value>AGE</value>
</param>
<param>
<name>msg</name>
<value>LOCAL CHURCH</value>
</param>
<param>
<name>msg</name>
<value>DISTRICT</value>
</param>
<param>
<name>udh</name>
<value></value>
</param>
</message>
After registration,they will receive a confirmation that they successfully registered as user and they will be allowed to inquire via SMS. Here’s the my php code:
inquire.php
<?php
// This will allow user to inquire about the latest news within the organization.
// load the nusoap libraries. These are slower than those built in PHP5 but don't require you to recompile PHP
require_once('nusoap.php');
$client = new nusoap_client('http://iplaypen.globelabs.com.ph:1881/axis2/services/Platform/sendSMS');
// set the character encoding, utf-8 is the standard.
$client->soap_defencoding = 'UTF-8';
// Call the SOAP method, note the definition of the xmlnamespace as the third parameter in the call and how the posted message is added to the message string
$client->call('sendSMS', array( 'uName' => '48dwi5',
'uPin' => '159597',
'MSISDN' => '09152886810',
'messageString' => 'Summer Camp 2013',
'Display' => '1',
'udh' => '',
'mwi' => '',
'coding' => '0' ),
"http://ESCPlatform/xsd");
?>
Here’s the xml format of sending inquiries via SMS. They will send INQ EVENT LOCATION TIME send to 23730731.
<?xml version="1.0" encoding="utf-8"?>
<message>
<param>
<name>id</name>
<value>2373094420110106170141</value>
</param>
<param>
<name>messageType</name>
<value>SMS</value>
</param>
<param>
<name>target</name>
<value>23730731</value>
</param>
<param>
<name>source</name>
<value>09152886810</value>
</param>
<param>
<name>msg</name>
<value>event</value>
</param>
<param>
<name>msg</name>
<value>location</value>
</param>
<param>
<name>msg</name>
<value>time</value>
</param>
<param>
<name>udh</name>
<value></value>
</param>
</message>
Here’s my callback URL to receive the message sent:
<?php
function send($number,$client)
{
$x=send("09152886810",$client);
echo $x;
}
# Load XML string from input
$xml = simplexml_load_file('php://input');
# Parse the XML for parameters
$sms = array();
$nodes = $xml->xpath('/message/param');
foreach($nodes as $node)
{
$param = (array) $node;
$sms[$param['name']] = $param['value'];
}
if($sms['messageType'] == 'SMS-NOTIFICATION') {
send();
list($action, $messagetype, $source, $type) =explode (" ",$client);
}elseif($sms['messageType'] == 'SMS') {
send();
list($action, $name, $age, $localchurch, $district) = explode(" ",$client);
}elseif($sms['messageType'] == 'SMS') {
send();
list($action, $event,$location,$time) = explode(" ", $client);
}
else {
echo "Unsupported Message Type";
}
?>