Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php header ("Content-Type: text/plain");
- function SendSMS ($host, $port, $username, $password, $phoneNoRecip, $msgText) {
- /* Parameters:
- $host - IP address or host name of the NowSMS server
- $port - "Port number for the web interface" of the NowSMS Server
- $username - "SMS Users" account on the NowSMS server
- $password - Password defined for the "SMS Users" account on the NowSMS Server
- $phoneNoRecip - One or more phone numbers (comma delimited) to receive the text message
- $msgText - Text of the message
- Additional NowSMS URL parameters can follow $msgText as additional parameters (e.g., "SMSCRoute=routename", "Sender=1234")
- */
- $fp = fsockopen($host, $port, $errno, $errstr);
- if (!$fp) {
- echo "errno: $errno \n";
- echo "errstr: $errstr\n";
- return $result;
- }
- $getString = "GET /?Phone=" . rawurlencode($phoneNoRecip) . "&Text=" . rawurlencode($msgText) . "&ReceiptRequested=Yes";
- /* Parse extra function parameters for more URL parameters */
- $numArgs = 6;
- while ($numArgs < func_num_args()) {
- $argString = func_get_arg($numArgs);
- $getString = $getString . "&" . substr($argString, 0, strpos($argString,'=')) . "=" . rawurlencode(substr($argString, strpos($argString,'=')+1));
- $numArgs += 1;
- }
- $getString = $getString . " HTTP/1.0\n";
- fwrite($fp, $getString);
- if ($username != "") {
- $auth = $username . ":" . $password;
- $auth = base64_encode($auth);
- fwrite($fp, "Authorization: Basic " . $auth . "\n");
- }
- fwrite($fp, "\n");
- $res = "";
- while(!feof($fp)) {
- $res .= fread($fp,1);
- }
- fclose($fp);
- return $res;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment