5
0
mirror of https://github.com/cwinfo/envayasms.git synced 2024-09-19 22:02:31 +00:00
envayasms/server/php/example/send_sms.php
2011-09-12 17:47:56 -07:00

45 lines
966 B
PHP
Executable File

<?php
/*
* Command line script to simulate sending an outgoing SMS from the server.
*
* The message will be queued on the server until the next time KalSMS checks for outgoing messages.
*/
require_once __DIR__."/config.php";
$arg_len = sizeof($argv);
if ($arg_len == 4)
{
$from = $argv[1];
$to = $argv[2];
$message = $argv[3];
}
else if ($arg_len == 3)
{
$from = $PHONE_NUMBERS[0];
$to = $argv[1];
$message = $argv[2];
}
else
{
error_log("Usage: php send_sms.php [<from>] <to> \"<message>\"");
error_log("Examples: ");
error_log(" php send_sms.php 16505551212 16504449876 \"hello world\"");
error_log(" php send_sms.php 16504449876 \"hello world\"");
die;
}
$id = uniqid("");
$filename = "$OUTGOING_DIR_NAME/$id.json";
file_put_contents($filename, json_encode(array(
'from' => $from,
'to' => $to,
'message' => $message,
'id' => $id
)));
echo "Message $id added to outgoing queue\n";