2011-09-12 23:53:38 +00:00
|
|
|
<?php
|
|
|
|
|
2011-09-13 00:47:56 +00:00
|
|
|
/*
|
|
|
|
* Command line script to simulate sending an outgoing SMS from the server.
|
|
|
|
*
|
2011-09-22 23:16:46 +00:00
|
|
|
* The message will be queued on the server until the next time
|
|
|
|
* EnvayaSMS checks for outgoing messages.
|
2011-09-13 00:47:56 +00:00
|
|
|
*/
|
2011-09-12 23:53:38 +00:00
|
|
|
|
|
|
|
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";
|