Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
An easy to use gem for the PSWinCom SMS Gateway
Ruby
branch: master

Merge pull request #6 from rogerkk/latin1-encoding

Ensure ISO-8859-1 when sending to gateway
latest commit 759cb9fb0d
@tormaroe tormaroe authored
Failed to load latest commit information.
bin
lib Ensure ISO-8859-1 when sending to gateway
spec Ensure ISO-8859-1 when sending to gateway
.gitignore
CREDITS.md
LICENSE Uploading version 0.1.1
README.md Added support for setting the rcpreq parameter in the request.
pswincom.gemspec
rakefile

README.md

PSWinCom Ruby Gem

A Ruby interface to the PSWinCom SMS Gateway.

Installation

gem install pswincom

Basic Usage

To use this gem, you will need sign up for a Gateway account with PSWinCom. Demo account are available.

This piece of code demonstrates how to send a simple SMS message:

require 'rubygems'
require 'pswincom'

api = PSWinCom::API.new 'username', 'password'
api.send_sms 4712345678, 'This is a test SMS' 

You can also send multiple messages in a single request, like this:

api = PSWinCom::API.new 'username', 'password'
api.add_sms 4712345678, 'This is a test SMS' 
api.add_sms 4712345679, 'This is another test SMS' 
api.send_sms 

Properties

Receiver and message text are the two mandatory properties when sending a message. You may specify additional properties by using a hash as the last argument to send_sms.

For instance this is how you would specify a sender:

api.send_sms 4712345678, 'This is a test', :sender => 'Ruby'

Properties currently supported are:

  • :sender
  • :TTL - time to live in minutes
  • :deliverytime - a Time object specifying when to send the message
  • :tariff - the amount (in local currency as cents/"ører") to charge the receiver
  • :servicecode - ServiceCode for sending GAS messages. Requires that :tariff is set. See wiki for details.
  • :rcpreq - Set to true to indicate that a delivery report forward is desired for this message. See wiki for details.

Specifying Host

The gem is set to use a particular PSWinCom SMS Gateway by default. The host can be changed globaly by setting api_host:

PSWinCom::API.api_host = 'http://some.server/sms'

Modes

For testing purposes the API provides a couple of modes you can set globally to control how the gem works.

PSWinCom::API.test_mode = true

.. will make you use the API without actually sending any messages.

PSWinCom::API.debug_mode = true

.. will make the API output debug information to standard out.

Command-line SMS tool

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

To simplify the usage of the tool you may create a YAML configuration file in your home directory, in a file called .pswincom that resembles the following:

username: your_username
password: your_password
from: your_nick_or_something
host: optionally_override_api_host

If you don't provide these options in the .pswincom file, you can specify them directly at the command-line.And only username and password are required. Run 'sms' without any arguments for a full list of options.

You can then use the sms tool to send a message:

sms 4712345678 "Message from PSWinCom"

License

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

Something went wrong with that request. Please try again.