Created
September 17, 2009 21:04
-
-
Save ultraspeed/188717 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_resource' | |
class TextMessage < ActiveResource::Base | |
self.site = "http://api.esendex.com/" | |
self.user = "[email protected]" | |
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