Make sure you have the PHP CLI package installed. On my Ubuntu VPS I had to run:
$ apt-get install php5-cli
Check that it's installed:
$ /usr/bin/php -v
Then, create a file called something like sendsms.php
with contents similar to this:
#!/usr/bin/php -q
<?php
// command line parameters are in the format:
// key1 value1 .. keyN valueN number message
$username = "";
$password = "";
$apikey = "";
// process pairs of arguments up to the last two
for ($x = 0; $x < ($argc - 3); $x++)
{
if ($argv[$x] == "-u") $username = $argv[$x + 1];
if ($argv[$x] == "-p") $password = $argv[$x + 1];
if ($argv[$x] == "-k") $apikey = $argv[$x + 1];
}
$number = $argv[$argc - 2];
$message = $argv[$argc - 1];
// To do: call the SMS API
// For now just output the info
echo("Username = " . $username . "\r\n");
echo("Password = " . $password . "\r\n");
echo("API key = " . $apikey . "\r\n");
echo("Number = " . $number . "\r\n");
echo("Message = " . $message . "\r\n");
?>
Make sure the file has execute permissions:
chmod 755 sendsms.php
And then run it from the current folder like this:
$ ./sendsms.php -u your_username -p your_password -k your_api_key 447771234567 'Hello from CLI'