Hardware Reference
In-Depth Information
Sending Messages
This is the easiest part to get working, because both of the services mentioned (which I'll use as an example) provide
an API that takes a basic HTTP request and translates it into a text message. My code for mxsms-intelli , for example,
is as follows:
#!/usr/bin/php
<?php
include 'IntelliSMS.php';
array_shift($argv); // ignore program name
$type = array_shift($argv);
$toAddr = array_shift($argv);
$message = implode(" ", $argv);
$fromAddr = "MinervaHome";
$objIntelliSMS = new IntelliSMS();
$objIntelliSMS->Username = 'MyUserName';
$objIntelliSMS->Password = 'MyPassword';
$objIntelliSMS->MaxConCatMsgs = 1;
$result = $objIntelliSMS->SendMessage($toAddr, $message, $fromAddr);
?>
And that, believe it or not, is all the code that's necessary! You invoke it as suspected with the following:
mxsms-intelli sms 012345678 This stuff really works
Although text messages can be extended over several packets, I have limited the maximum here to 1, in case of
excessive output from a runaway application. Naturally, the clever formatting is hidden inside the library, which is
similar to that use in the Txtlocal version, exposed here:
#!/usr/bin/php
<?php
array_shift($argv); // ignore program name
$type = array_shift($argv);
$toAddr = array_shift($argv);
$message = implode(" ", $argv);
$fromAddr = "MinervaHome";
# Things get different now...
$uname = ' MyUserName';
$pword = 'MyPassword';
$message = urlencode($message);
Search WWH ::




Custom Search