johnmahugu

http-sms

May 25th, 2016
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.21 KB | None | 0 0
  1. <?php
  2.   $strResult = "n/a";
  3.   $strLastResponse = "";
  4.  
  5.   $objHttp = new COM("AxSms.Http");    
  6.   $objSmsConstants = new COM("AxSms.Constants");    
  7.   $objHttp->LogFile = sys_get_temp_dir()."Http.log";
  8.   // Windows default: 'C:\Windows\Temp\Http.log'
  9.  
  10.   //Form submitted
  11.   if (isset($_POST["btnSendMessage"]))
  12.   {
  13.     $objSmsMessage = new COM("AxSms.Message");  
  14.     $objSmsMessage->Clear();
  15.     $obj;
  16.    
  17.     $objSmsMessage->Body = $_POST['txtBody'];
  18.     $objSmsMessage->ToAddress = $_POST['txtToAddress'];
  19.    
  20.     $objHttp->Clear();
  21.     $objHttp->Url = $_POST['txtUrl'];
  22.    
  23.     $obj = $objSmsMessage;
  24.     $objHttp->SendSms($obj, $objSmsConstants->MULTIPART_ACCEPT);
  25.    
  26.     $strResult = $objHttp->LastError . ": " . $objHttp->GetErrorDescription($objHttp->LastError);
  27.     $strLastResponse = $objHttp->LastResponseCode;
  28.   }
  29.  
  30.   function GetSmsDemoAccountInfo()
  31.   {
  32.     // NOTE: during installation of the SMS Component, a unique login and password is created for you.
  33.     // This login and password can be used to send a few SMS messages through the smpp.activexperts-labs.com gateway, for free
  34.    
  35.     $objDemoAccount = new COM("AxSms.DemoAccount");  
  36.     global $objSmsConstants;
  37.     $strInfo = "post.activexperts-labs.com:8080/sendsms/default.asp";
  38.     $strInfo .= "?username=".$objDemoAccount->SystemId;
  39.     $strInfo .= "&password=".$objDemoAccount->Password;
  40.     $strInfo .= "&text=".$objSmsConstants->HTTP_PLACEHOLDER_BODY;
  41.     $strInfo .= "&to=".$objSmsConstants->HTTP_PLACEHOLDER_TOADDRESS;
  42.    
  43.     return $strInfo;
  44.   }
  45.  
  46. //HTML-CSS layout includes, no code there!
  47. include('css/Header.html');
  48. include('css/Menu.html');
  49. ?>
  50.     <div class="container">
  51.       <h1>SMS Component PHP HTTP Sample</h1>
  52.       <hr />
  53.       <p>
  54.         The HTTP protocol is used for medium volume SMS messaging. Messages are first
  55.         routed to the service provider via Internet/VPN. The provider delivers the
  56.         messages to the recipient&#39;s phone. If you are not subscribed to a provider, use
  57.         the ActiveXperts gateway to send 10 SMS messages for free.
  58.       </p>
  59.       <form action="http.php" method="post">
  60.         <h2>SMS Component:</h2>
  61.         <h3>Build: <?php echo $objHttp->Build; ?>; Module: <?php echo $objHttp->Module; ?></h3>
  62.        
  63.         <!-- Connection URL -->
  64.         <label for="Url">Connection URL:</label>
  65.         <p>
  66.           <input type="text" id="Url" name="txtUrl" class="FullWidth" value="<?php echo GetSmsDemoAccountInfo(); ?>" />
  67.         </p>
  68.        
  69.         <!-- Empty row -->
  70.         <div class="clearRow"></div>
  71.        
  72.         <!-- ToAddress -->
  73.         <label for="ToAddress">ToAddress:</label>
  74.         <p>
  75.           <input type="text" id="ToAddress" name="txtToAddress" value="[ToAddress]" />
  76.           <a href="http://www.activexperts.com/support/xmstoolkit/?kb=Q4200015" target="_blank">Recipient number format</a>
  77.         </p>
  78.        
  79.         <!-- Body -->
  80.         <label for="Body">Body:</label>
  81.         <p>
  82.           <textarea id="Body" name="txtBody" style="height:55px;">Hello world send from ActiveXperts SMS Component!</textarea>
  83.         </p>
  84.        
  85.         <!-- Send button -->
  86.         <div class="clearLabel"></div>
  87.         <p>
  88.           <input type="submit" name="btnSendMessage" value="Send SMS Message!" />
  89.         </p>
  90.        
  91.         <!-- Empty row -->
  92.         <div class="clearRow"></div>
  93.        
  94.         <!-- Result -->
  95.         <label for="Result"><b>Result:</b></label>
  96.         <p>
  97.           <input type="text" id="Result" name="txtResult" class="FullWidth Bold" value="<?php echo $strResult; ?>" />
  98.         </p>
  99.        
  100.         <!-- Last Response -->
  101.         <label for="Response">Last Response:</label>
  102.         <p>
  103.           <input type="text" id="Response" name="txtLastResponse" class="FullWidth" value="<?php echo $strLastResponse; ?>" />
  104.         </p>
  105.       </form>
  106.       <p>
  107.         This demo uses the ActiveXperts SMS Component, an <a href="http://www.activexperts.com" target="_blank">ActiveXperts Software</a> product.<br />
  108.         <a href="index.php">Back to main page</a>
  109.       </p>          
  110.     </div><!-- /container -->
  111. <?php
  112. //HTML-CSS layout include, no code there!
  113. include('css/Footer.html'); ?>
Add Comment
Please, Sign In to add comment