Skip to content

Instantly share code, notes, and snippets.

@ultraspeed
Created September 17, 2009 21:04
Show Gist options
  • Save ultraspeed/188717 to your computer and use it in GitHub Desktop.
Save ultraspeed/188717 to your computer and use it in GitHub Desktop.
require 'active_resource'
class TextMessage < ActiveResource::Base
self.site = "http://api.esendex.com/"
self.user = "XXX@ultraspeed.com"
self.password = "XXX"
ESENDEX_API_REFERENCE = "XXX"
class << self
# Sends an SMS using the Esendex REST API
#
# == Attributes
#
# * <tt>to</tt> - Full mobile number to send message to
# * <tt>message</tt> - Message to be sent (should be under 160 characters)
def send(to, message)
body = %{<?xml version='1.0' encoding='UTF-8'?>
<messages>
<message>
<to>#{to}</to>
<body>#{message}</body>
<validity>0</validity>
</message>
</messages>}
connection.post("/v0.8/account/#{ESENDEX_API_REFERENCE}/messagedispatcher", body)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment