Exemple #1
0
#!/usr/local/bin/php
<?php 
/**
* Send SMS Messages via Clickatell
*
* @author       Jacques Marneweck <*****@*****.**>
* @copyright    2003-2010 Jacques Marneweck. All rights strictly reserved.
* @package      SMS_Clickatell
*/
require_once 'PEAR.php';
require_once 'SMS/Clickatell.php';
set_time_limit(0);
error_reporting(E_ALL);
if ($_SERVER['argc'] != 4) {
    die("Usage: {$_SERVER['argv'][0]} [msisdn] [subject] [message]");
}
$sms = new SMS_Clickatell();
$res = $sms->init(array('user' => 'username', 'pass' => 'password', 'api_id' => 'api_id'));
if (PEAR::isError($res)) {
    die($res->getMessage());
}
$res = $sms->auth();
if (PEAR::isError($res)) {
    die($res->getMessage());
}
$climsgid = md5(md5(uniqid(mt_rand(), true)) . md5(uniqid(rand(), true)));
$sent = $sms->sendmsg(array('to' => $_SERVER['argv'][1], 'text' => $_SERVER['argv'][3], 'msg_type' => 'SMS_TEXT', 'climsgid' => $climsgid));
if (PEAR::isError($sent)) {
    die($sent->getMessage());
}
Exemple #2
0
<?php 
/**
 * Send SMS Messages via Clickatell
 *
 * @author      Jacques Marneweck <*****@*****.**>
 * @copyright   2003-2008 Jacques Marneweck.  All rights strictly reserved.
 * @package     SMS_Clickatell
 */
require_once 'PEAR.php';
require_once 'SMS/Clickatell.php';
require_once 'Console/Getopt.php';
set_time_limit(0);
error_reporting(E_ALL);
$options = getopt("d:m:");
if (!isset($options['d']) || !isset($options['m'])) {
    die("This script is supposed to be called from Exim/Nagios.");
}
$sms = new SMS_Clickatell();
$res = $sms->init(array('user' => 'username', 'pass' => 'password', 'api_id' => 'api_id'));
if (PEAR::isError($res)) {
    die($res->getMessage());
}
$res = $sms->auth();
if (PEAR::isError($res)) {
    die($res->getMessage());
}
$climsgid = md5(md5(uniqid(mt_rand(), true)) . md5(uniqid(rand(), true)) . md5(uniqid(`hostname`)));
$sent = $sms->sendmsg(array('to' => $options['d'], 'text' => $options['m'], 'msg_type' => 'SMS_TEXT', 'climsgid' => $climsgid));
if (PEAR::isError($sent)) {
    die($sent->getMessage());
}