5
0
mirror of https://github.com/cwinfo/envayasms.git synced 2024-11-13 20:00:26 +00:00
envayasms/server/php/example/send_sms.php

46 lines
973 B
PHP
Raw Normal View History

<?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
*/
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";