What is it?

A Ruby interface to the Clickatell SMS gateway API.

Installing

Download the latest version of gem or install using RubyGems.

$ sudo gem install clickatell

Getting the latest version from Subversion:

& svn co svn://lukeredpath.co.uk/var/svn/opensource/clickatell/trunk clickatell-trunk

The basics

To use this gem, you will need sign up for an account at the Clickatell website. Once you are registered and logged into your account centre, you should add an HTTP API connection to your account. This will give you your API_ID.

Demonstration of usage

You can now use the library directly. You will need your API_ID as well as your account username and password.


require 'rubygems'
require 'clickatell'

connection = Clickatell::Connection.new('your_api_id', 'your_username', 'your_password')
connection.send_message('447771234567', 'Hello from clickatell')

Full documentation for the API is available in the RDocs.

Command-line SMS Utility

The Clickatell gem also comes with a command-line utility that will allow you to send an SMS directly from the command-line.

You will need to create a YAML configuration file in your home directory, in a file called .clickatell that resembles the following:


# ~/.clickatell
api_key: your_api_id
username: your_username
password: your_password

You can then use the sms utility to send a message to a single recipient:


$ sms 447771234567 'Hello from clickatell'

Alternatively, you can specify your authentication details manually by passing in options to the sms command.


$ sms -u your_username -p your_password -k your_api_key 447771234567 'Hello from clickatell'

These values will take presedence over any values in your ~/.clickatell file.

You can also use the sms utility to check your Clickatell account balance:


$ sms --show-balance

Run sms without any arguments for a full list of options.

License

This code is free to use under the terms of the MIT license.

Contact

Comments are welcome. Send an email to Luke Redpath email.