2011-09-12 23:53:38 +00:00
|
|
|
<?php
|
|
|
|
|
2011-09-13 00:47:56 +00:00
|
|
|
/*
|
2012-04-04 21:16:26 +00:00
|
|
|
* Command line script to send an outgoing SMS from the server.
|
2011-09-13 00:47:56 +00:00
|
|
|
*
|
2012-04-04 21:16:26 +00:00
|
|
|
* This example script queues outgoing messages using the local filesystem.
|
|
|
|
* The messages are sent the next time EnvayaSMS sends an ACTION_OUTGOING request to www/gateway.php.
|
2011-09-13 00:47:56 +00:00
|
|
|
*/
|
2011-09-12 23:53:38 +00:00
|
|
|
|
|
|
|
require_once __DIR__."/config.php";
|
2012-04-04 21:16:26 +00:00
|
|
|
require_once dirname(__DIR__)."/EnvayaSMS.php";
|
2011-09-12 23:53:38 +00:00
|
|
|
|
2012-04-04 21:16:26 +00:00
|
|
|
if (sizeof($argv) == 3)
|
2011-09-12 23:53:38 +00:00
|
|
|
{
|
|
|
|
$to = $argv[1];
|
2012-04-04 21:16:26 +00:00
|
|
|
$body = $argv[2];
|
2011-09-12 23:53:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-04-04 21:16:26 +00:00
|
|
|
error_log("Usage: php send_sms.php <to> \"<message>\"");
|
|
|
|
error_log("Example: ");
|
2011-09-12 23:53:38 +00:00
|
|
|
error_log(" php send_sms.php 16504449876 \"hello world\"");
|
|
|
|
die;
|
|
|
|
}
|
|
|
|
|
2012-04-04 21:16:26 +00:00
|
|
|
$message = new EnvayaSMS_OutgoingMessage();
|
|
|
|
$message->id = uniqid("");
|
|
|
|
$message->to = $to;
|
|
|
|
$message->message = $body;
|
2011-09-12 23:53:38 +00:00
|
|
|
|
2012-04-04 21:16:26 +00:00
|
|
|
file_put_contents("$OUTGOING_DIR_NAME/{$message->id}.json", json_encode($message));
|
|
|
|
|
|
|
|
echo "Message {$message->id} added to filesystem queue\n";
|