SMS library for Moodle
As always this document is a draft and written as personal notes. This is not a definitive guide.
NOTICE! This is only a library. This package does not contain any ready-made User Inteface for sending messages.
This SMS library supports two SMS Gateways and one SMS service:
- Kannel WAP/SMS Gateway (small guide to install and configure)
- TextMagic SMS service. If you want to use their SMS API, you need to have knowledge of their HTTPS API
- NowSMS SMS/MMS Gateway (does not include MMS sending at this point, this is on my TODO list)
- Commercial software (and expensive one)
- Clickatell SMS Service
The SMS library download
WARNING!!! Use at your own risk!
- smslib-1.1.zip 39.5 kB (2011-06-19 02:13:00)
- smslib-1.1.tar.gz 31.9 kB (2011-06-19 02:12:47)
First release Support for TextMagic's service. Send, account, message_status, receive, delete_reply and check_number commands are supported in this release.
- smslib-1.0.zip 34.6 kB (2007-07-10 14:51:33)
- smslib-1.0.tar.gz 28.7 kB (2007-07-10 14:51:20)
Updated: Allow multiple recipients for one message ( recipients can be an array ). Changed HTTP GET request to version 1.1
Older versions
- smslib.zip 33.7 kB (2007-06-24 04:15:57)
- smslib.tar.gz 27.5 kB (2007-06-24 04:19:38)
License
smslib is published under the GNU General Public License (GPL) and Connection class library is published under MIT License.
Installation
- Just unzip the package into /moodleinstalldir/lib/ directory.
- Add the configuration variables into config.php file.
Settings
The basic settings for all the gateways are:
$CFG->gwhost = 'xxx.xxx.xxx.xxx'; // IP address or a hostname of the sms gateway
$CFG->gwproto = 'http'; // http or https.
$CFG->gwport = 80; // Port number to connec to.
$CFG->gwuser = 'username'; // Username of the gateway or account.
$CFG->gwpass = 'password'; // Password of the gateway or account.
$CFG->gwsocketinterface = 'fsockopen'; // Socket interface to use.
$CFG->gwclient = 'kannel'; // Use this gateway library (kannel, nowsms or clickatell).
If you're using Clickatell, you'll need to define few extra variables:
$CFG->ct_api_id = '123456'; // You're Clickatell accounts api_id
$CFG->ct_balancelimit = 5; // A limit which stops message routing to the gateway.
Create a test script to test the installation:
<?php
require_once('path/to/moodle/config.php');
require_once($CFG->libdir .'/sms/smslib.php');
// Load the sms object
$sms = SMS::Loader($CFG);
// Define the recipient of this sms message.
// Number must be in international form including '+' -sign in front of it.
$to = '+358451234567';
// Or multiple recipients
// $to = array('+35840123456','+35850456789','+35845123789');
// The message it self.
$message = 'This is a test message!';
// Send the message.
if ( $sms->send_message($to, $message) ) {
echo "SMS Message sent!";
} else {
echo "Error while sending SMS Message!";
}
?>
After that you should be able to develop your own SMS enabled Modules, blocks or whatever you feel like.