Home

Search the wiki

»

API Documentation


Mobile Payment

PHP Autoresponder source code sample

RSS


File autoresponder.php

<?
//********************************************************************
// PSWinCom SMS Gateway Simple autoresponder PHP Example
// Receiving MO SMS with HTTP POST from PSWinCom Gateway
// Sending SMS with XML over TCP
// Disclaimer: Code initially written in PHP4, but tested on PHP5 
//********************************************************************

// Receiving Sendernumber and message text from PSWinCom Gateway MO SMS request.
$sendernumber = $_POST["SND"];
$messagetext = $_POST["TXT"];

// Writing XML Document
$xml[] = "<?xml version=\"1.0\"?>";
$xml[] = "<!DOCTYPE SESSION SYSTEM \"pswincom_submit.dtd\">";
$xml[] = "<SESSION>";
$xml[] = "<CLIENT>usernamehere</CLIENT>";
$xml[] = "<PW>passwordhere</PW>";
$xml[] = "<MSGLST>";

$xml[] = "<MSG>";
$xml[] = "<TEXT>You sent" . $messagetext . "</TEXT>";
$xml[] = "<RCV>" . $sendernumber . "</RCV>";
$xml[] = "<SND>4741716100</SND>"; 
$xml[] = "</MSG>";

$xml[] = "</MSGLST>";
$xml[] = "</SESSION>";
$xmldocument = join("\r\n", $xml)."\r\n\r\n";

// Address of the PSWinCom SMS Gateway
$host="sms.pswin.com";
$port = 1111;

// Opens a connection to the gateway
$pswincomsmsgateway = fsockopen ($host, $port, $errno, $errstr);

// Errormessage if connection fails
if (!$pswincomsmsgateway) { $result = "Error: could not open socket connection"; }
else
{

// Put the xml document to the gateway
fputs ($pswincomsmsgateway, $xmldocument);

// Receives XML back from the gateway, stores as $result
while ( ($response = fgets($pswincomsmsgateway)) != false ) {
   $response = trim($response);
global $result;
$result .= $response; // result can be used for logging
}
}
 
// Closes the connection
fclose ($pswincomsmsgateway);
?> 


Gateway interfaces: | XML | HTTP | SMTP | SOAP | SFTP BatchLoader
Intouch interfaces: REST | Syncopy

© Copyright Link Mobility ASA.





GuestLogin