XML Statistics for individual SMSC Connection

XML Statistics for individual SMSC Connection SearchSearch

SMS & MMS Technical Forum » NowSMS Support - SMS Issues (Product Support Only) » Archive through May 19, 2016 » XML Statistics for individual SMSC Connection « Previous || Next »
Author Message
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 5428
Registered: 08-2008
Posted on Thursday, August 27, 2015 - 01:48 pm:   

From the support mailbox...



When I am trying to query the number of messages for Today using below code, I am getting results from ALL SMSC connections. How can I get the number of ONLY one SMSC connection? Snippet of my XML is below for your reference.


This question references the PHP example at http://www.nowsms.com/nowsms-status-query-with-php

And the XML status query interface described at http://www.nowsms.com/xml-status-query-for-smsc-connection-status-and-statistics

The PHP example loads the current status via HTTP into a simple XML element with the following two lines of code:

$xmldata = file_get_contents (""); 
$xml = simplexml_load_string($xmldata);

Once loaded, various statistics can be easily extracted from the XML. For example, to retrieve the number of SMS messages sent today, the following syntax can be used:


Statistics are also available for each SMSC and MMS connection.

In the XML, each SMSC connection has a separate <SMSCStatus> element, like this:

<Name>SMPP – xps5:9000</Name>
<Name>SMPP – xps5:9001</Name>

To retrieve the statistics for an individual connection, it is necessary to iterate through the XML using the foreach directive.

The following is a simple example that outputs total messages sent today, then outputs the number of messages sent by each connection:

echo "SMS Sent Today = " . $xml->SMSSent->MessagesToday . "<br/>\r\n"; 

// For each <SMSCStatus> node, we echo the name and sent messages count.
foreach ($xml->SMSCStatus as $SMSCStatus) {
echo "For " . $SMSCStatus->Name . ", SMS Sent Today = " . $SMSCStatus->MessagesToday . "<br/>\r\n";

NowSMS Support

Login Login / Register Logout Logout Search Last 30 Days Topics Topics