Guest User

Untitled

a guest
Sep 12th, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.72 KB | None | 0 0
  1. <?php header ("Content-Type: text/plain");
  2.  
  3. function SendSMS ($host, $port, $username, $password, $phoneNoRecip, $msgText) {
  4.  
  5. /* Parameters:
  6.     $host - IP address or host name of the NowSMS server
  7.     $port - "Port number for the web interface" of the NowSMS Server
  8.     $username - "SMS Users" account on the NowSMS server
  9.     $password - Password defined for the "SMS Users" account on the NowSMS Server
  10.     $phoneNoRecip - One or more phone numbers (comma delimited) to receive the text message
  11.     $msgText - Text of the message
  12.     Additional NowSMS URL parameters can follow $msgText as additional parameters (e.g., "SMSCRoute=routename", "Sender=1234")
  13. */
  14.  
  15.     $fp = fsockopen($host, $port, $errno, $errstr);
  16.     if (!$fp) {
  17.         echo "errno: $errno \n";
  18.         echo "errstr: $errstr\n";
  19.         return $result;
  20.     }
  21.  
  22.     $getString = "GET /?Phone=" . rawurlencode($phoneNoRecip) . "&Text=" . rawurlencode($msgText) . "&ReceiptRequested=Yes";
  23.     /* Parse extra function parameters for more URL parameters */
  24.     $numArgs = 6;
  25.     while ($numArgs < func_num_args()) {
  26.        $argString = func_get_arg($numArgs);
  27.        $getString = $getString . "&" . substr($argString, 0, strpos($argString,'=')) . "=" . rawurlencode(substr($argString, strpos($argString,'=')+1));
  28.        $numArgs += 1;
  29.     }
  30.     $getString = $getString . " HTTP/1.0\n";
  31.    
  32.     fwrite($fp, $getString);
  33.     if ($username != "") {
  34.        $auth = $username . ":" . $password;
  35.        $auth = base64_encode($auth);
  36.        fwrite($fp, "Authorization: Basic " . $auth . "\n");
  37.     }
  38.     fwrite($fp, "\n");
  39.  
  40.     $res = "";
  41.  
  42.     while(!feof($fp)) {
  43.         $res .= fread($fp,1);
  44.     }
  45.     fclose($fp);
  46.    
  47.  
  48.     return $res;
  49. }
  50.  
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment