Advertisement
Guest User

kip

a guest
Nov 23rd, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.16 KB | None | 0 0
  1. <?php
  2.  
  3. include_once("ViaNettSMS.php");
  4.  
  5. // Declare variables.
  6. $Username = "YourUsername";
  7. $Password = "YourPassword";
  8. $MsgSender = "YourSender, example: a phone number like 4790000000";
  9. $DestinationAddress = "Receiver - A phone number";
  10. $Message = "Hello World!";
  11.  
  12. // Create ViaNettSMS object with params $Username and $Password
  13. $ViaNettSMS = new ViaNettSMS($Username, $Password);
  14. try
  15. {
  16.     // Send SMS through the HTTP API
  17.     $Result = $ViaNettSMS->SendSMS($MsgSender, $DestinationAddress, $Message);
  18.     // Check result object returned and give response to end user according to success or not.
  19.     if ($Result->Success == true)
  20.         $Message = "Message successfully sent!";
  21.     else
  22.         $Message = "Error occured while sending SMS<br />Errorcode: " . $Result->ErrorCode . "<br />Errormessage: " . $Result->ErrorMessage;
  23. }
  24. catch (Exception $e)
  25. {
  26.     //Error occured while connecting to server.
  27.     $Message = $e->getMessage();
  28. }
  29.  
  30. ?>
  31.  
  32. <html>
  33.     <head>
  34.         <title>ViaNettSMS Example</title>
  35.     </head>
  36.     <body>
  37. <?php
  38. echo "          <p><strong>SMS Result</strong><br />Status: $Message</p>";
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement