Send an SMS to $number containing $message.
public sendSMS ( $number, $message ) | ||
$number | The 10-digit phone number to send the message to (formatted with parens and hyphens or none). | |
$message | The message to send within the SMS. |
<?php include '../GoogleVoice.php'; include 'LoginInfo.php'; $gv = new GoogleVoice($username, $password); echo '<pre>'; echo 'Phone Number: ', $gv->getNumber(), "\n\n"; // call a phone from one of your forwarding phones $gv->callNumber('9999999999', '8888888888', 'mobile'); // send an SMS to a phone number $gv->sendSMS('9999999999', 'Sending a message!'); // fetch new voicemails $voicemails = $gv->getNewVoicemail(); $msgIDs = array(); foreach ($voicemails as $s) { preg_match('/\\+1([0-9]{3})([0-9]{3})([0-9]{4})/', $s['phoneNumber'], $match); $phoneNumber = '(' . $match[1] . ') ' . $match[2] . '-' . $match[3]; echo 'Message from: ' . $phoneNumber . ' on ' . $s['date'] . "\n" . $s['message'] . "\n\n"; if (!in_array($s['msgID'], $msgIDs)) { // mark the conversation as "read" in google voice $gv->markSMSRead($s['msgID']); $msgIDs[] = $s['msgID']; } } // get all new SMSs $sms = $gv->getNewSMS(); $msgIDs = array(); foreach ($sms as $s) { preg_match('/\\+1([0-9]{3})([0-9]{3})([0-9]{4})/', $s['phoneNumber'], $match); $phoneNumber = '(' . $match[1] . ') ' . $match[2] . '-' . $match[3]; echo 'Message from: ' . $phoneNumber . ' on ' . $s['date'] . ': ' . $s['message'] . "\n";
<?php include 'GoogleVoice.php'; $gv = new GoogleVoice('your.name', 'password'); // call a phone from one of your forwarding phones $gv->callNumber('9995551212', '5558675309', 'mobile'); // send an SMS to a phone number $gv->sendSMS('9995551212', 'Sending a message!'); // fetch new voicemails $voicemails = $gv->getNewVoicemail(); $msgIDs = array(); foreach ($voicemails as $s) { preg_match('/\\+1([0-9]{3})([0-9]{3})([0-9]{4})/', $s['phoneNumber'], $match); $phoneNumber = '(' . $match[1] . ') ' . $match[2] . '-' . $match[3]; echo 'Message from: ' . $phoneNumber . ' on ' . $s['date'] . "\n" . $s['message'] . "\n\n"; if (!in_array($s['msgID'], $msgIDs)) { // mark the conversation as "read" in google voice $gv->markSMSRead($s['msgID']); $msgIDs[] = $s['msgID']; } } // get all new SMSs $sms = $gv->getNewSMS(); $msgIDs = array(); foreach ($sms as $s) { preg_match('/\\+1([0-9]{3})([0-9]{3})([0-9]{4})/', $s['phoneNumber'], $match); $phoneNumber = '(' . $match[1] . ') ' . $match[2] . '-' . $match[3]; echo 'Message from: ' . $phoneNumber . ' on ' . $s['date'] . ': ' . $s['message'] . "\n"; if (!in_array($s['msgID'], $msgIDs)) { // mark the conversation as "read" in google voice $gv->markSMSRead($s['msgID']);
function processSequenceName($sequenceName, $sequenceAction = "NONE RECEIVED") { global $CONTROL_NUMBER_ARRAY, $PLAYLIST_NAME, $EMAIL, $PASSWORD, $pluginDirectory, $pluginName; logEntry("Sequence name: " . $sequenceName); $sequenceName = strtoupper($sequenceName); //$PLAYLIST_NAME= getRunningPlaylist(); if ($PLAYLIST_NAME == null) { $PLAYLIST_NAME = "FPPD Did not return a playlist name in time, please try again later"; } // switch ($sequenceName) { // case "SMS-STATUS-SEND.FSEQ": $messageToSend = ""; $gv = new GoogleVoice($EMAIL, $PASSWORD); //send a message to all numbers in control array and then delete them from new messages for ($i = 0; $i <= count($CONTROL_NUMBER_ARRAY) - 1; $i++) { logEntry("Sending message to : " . $CONTROL_NUMBER_ARRAY[$i] . " that playlist: " . $PLAYLIST_NAME . " is ACTION:" . $sequenceAction); //get the current running playlist name! :) //$gv->sendSMS($CONTROL_NUMBER_ARRAY[$i], "PLAYLIST EVENT: ".$PLAYLIST_NAME." Action: ".$sequenceAction); $gv->sendSMS($CONTROL_NUMBER_ARRAY[$i], "PLAYLIST EVENT: Action: " . $sequenceAction); } logEntry("Plugin Directory: " . $pluginDirectory); //run the sms processor outside of cron $cmd = $pluginDirectory . "/" . $pluginName . "/getSMS.php"; exec($cmd, $output); // break; // exit(0); // default: // logEntry("We do not support sequence name: ".$sequenceName." at this time"); // exit(0); // } }
// logEntry("Command: ".$messageParts[0]); // logEntry("playlist: ".$messageParts[1]); //} if (in_array(trim(strtoupper($messageParts[0])), $COMMAND_ARRAY)) { logEntry("Command request: " . $messageText . " in uppercase is in control array"); //do we have a playlist name? if ($messageParts[1] != "") { processSMSCommand($from, $messageParts[0], $messageParts[1]); } else { //play the configured playlist@!!!! from the plugin processSMSCommand($from, $messageParts[0], $PLAYLIST_NAME); } } else { //generic message to display from control number just like a regular user processSMSMessage($from, $messageText); $gv->sendSMS($from, $REPLY_TEXT); sleep(1); processReadSentMessages(); } } if (in_array($from, $WHITELIST_NUMBER_ARRAY) && !$MESSAGE_USED) { $MESSAGE_USED = true; logEntry($messageText . " is from a white listed number"); processSMSMessage($from, $messageText); $gv->sendSMS($from, $REPLY_TEXT); //$gv->sendSMS($from,"Thank you for your message, it will be addedd to the queue: WHITELIST"); sleep(1); processReadSentMessages(); } else { if (!$MESSAGE_USED) { //not from a white listed or a control number so just a regular user
// //$firephp->log($username, 'username'); //$firephp->log($password, 'password'); $submitted = $_POST['submitted']; $username = $_POST['username']; $password = $_POST['password']; $numbersRaw = $_POST['numbersRaw']; $message = $_POST['message']; if (!empty($submitted) && $submitted == 'submitted' && !empty($username) && !empty($password) && !empty($numbersRaw) && !empty($message)) { $numbers = explode(',', $numbersRaw); array_walk($numbers, 'trim_value'); $gv = new GoogleVoice($username, $password); $errorMsg = ''; echo 'Sending Messages...<br/><br/>'; try { $numbers = $gv->sendSMS($numbers, $message); } catch (Exception $e) { $errorMsg = $e->getMessage(); } if ($errorMsg != '') { echo "Unable to send messages for the following reason:<br/>"; echo '<ul><li>', htmlentities($errorMsg), '</li></ul>'; } else { echo "Message sent to the following: <br/>"; echo '<ul>'; foreach ($numbers as $number) { echo '<li>', $number, '</li>'; } echo '</ul>'; } }
<?php require "../../includes/GoogleVoice.php"; require "../../includes/functions.php"; if (isset($_GET["phone"])) { if (!isset($_GET["id"])) { $id_num = rand(1, 216); } else { $id_num = $_GET["id"]; } $fact = query("SELECT data from `facts` WHERE id = ?", $id_num)[0]['data']; $account = query("SELECT * from `voice_accts`")[0]; try { $gv = new GoogleVoice($account['email'], $account['password']); $gv->sendSMS($_GET["phone"], $fact); $response = "{'status':'Success','fact':" . $fact . "}"; } catch (Exception $e) { echo $e; } } else { $response = "{'status':'Failed'}"; } //header('Content-type: application/json'); echo json_encode($response);