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

34 lines
862 B
PHP
Raw Permalink Normal View History

<?php
2011-09-13 00:47:56 +00:00
/*
* Command line script to send an outgoing SMS from the server.
2011-09-13 00:47:56 +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
*/
require_once __DIR__."/config.php";
require_once dirname(__DIR__)."/EnvayaSMS.php";
if (sizeof($argv) == 3)
{
$to = $argv[1];
$body = $argv[2];
}
else
{
error_log("Usage: php send_sms.php <to> \"<message>\"");
error_log("Example: ");
error_log(" php send_sms.php 16504449876 \"hello world\"");
die;
}
$message = new EnvayaSMS_OutgoingMessage();
$message->id = uniqid("");
$message->to = $to;
$message->message = $body;
file_put_contents("$OUTGOING_DIR_NAME/{$message->id}.json", json_encode($message));
echo "Message {$message->id} added to filesystem queue\n";