Guest User

Untitled

a guest
Jul 15th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. <?
  2. //********************************************************************
  3. // PSWinCom SMS Gateway Simple autoresponder PHP Example
  4. // Receiving MO SMS with HTTP POST from PSWinCom Gateway
  5. // Sending SMS with XML over TCP
  6. // Disclaimer: Code initially written in PHP4, but tested on PHP5
  7. //********************************************************************
  8.  
  9. // Receiving Sendernumber and message text from PSWinCom Gateway MO SMS request.
  10. $sendernumber = $_POST["SND"];
  11. $messagetext = $_POST["TXT"];
  12.  
  13. // Writing XML Document
  14. $xml[] = "<?xml version=\"1.0\"?>";
  15. $xml[] = "<!DOCTYPE SESSION SYSTEM \"pswincom_submit.dtd\">";
  16. $xml[] = "<SESSION>";
  17. $xml[] = "<CLIENT>usernamehere</CLIENT>";
  18. $xml[] = "<PW>passwordhere</PW>";
  19. $xml[] = "<MSGLST>";
  20.  
  21. $xml[] = "<MSG>";
  22. $xml[] = "<TEXT>You sent" . $messagetext . "</TEXT>";
  23. $xml[] = "<RCV>" . $sendernumber . "</RCV>";
  24. $xml[] = "<SND>4741716100</SND>";
  25. $xml[] = "</MSG>";
  26.  
  27. $xml[] = "</MSGLST>";
  28. $xml[] = "</SESSION>";
  29. $xmldocument = join("\r\n", $xml)."\r\n\r\n";
  30.  
  31. // Address of the PSWinCom SMS Gateway
  32. $host="sms.pswin.com";
  33. $port = 1111;
  34.  
  35. // Opens a connection to the gateway
  36. $pswincomsmsgateway = fsockopen ($host, $port, $errno, $errstr);
  37.  
  38. // Errormessage if connection fails
  39. if (!$pswincomsmsgateway) { $result = "Error: could not open socket connection"; }
  40. else
  41. {
  42. // Put the xml document to the gateway
  43. fputs ($pswincomsmsgateway, $xmldocument);
  44.  
  45. // Receives XML back from the gateway, stores as $result
  46. while ( ($response = fgets($pswincomsmsgateway)) != false ) {
  47. $response = trim($response);
  48. global $result;
  49. $result .= $response; // result can be used for logging
  50. }
  51. }
  52.  
  53. // Closes the connection
  54. fclose ($pswincomsmsgateway);
  55. ?>
Add Comment
Please, Sign In to add comment