Forum: Ruby on Rails Sending SMS Messages From Your Rails Application Usng Clickatell GEM

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Walter Lockhart (Guest)
on 2008-11-07 15:17
(Received via mailing list)
Hi Group,

I have just read and attempted to implement Luke R.'s example:

http://www.lukeredpath.co.uk/2007/8/29/sending-sms...

Unfortunately, I can't get it to work.

I signed up for a Clickatell Account.

I installed the Clickatell GEM.

The following paragraphs describe my app.

# controllers/sms.rb:
require 'clickatell'

class SMS

  def initialize(config)
    @config = config
  end

  def create(recipient, message_text)
    api.send_message(recipient, message_text)
  end

  private

    def api
      @api ||= Clickatell::API.authenticate(
        @config[:api_key],
        @config[:username],
        @config[:password])
    end

end

# config/clickatell.yml:
api_key: 9999999
username: abcdefg
password: hijklmno

# config/environments/development.rb
CLICKATELL_CONFIG = YAML.load(File.open(File.join(RAILS_ROOT,
'config', 'clickatell.yml')))

# config/routes.rb:
ActionController::Routing::Routes.draw do |map|
  map.resource :sms
end

# app/views/sms/new.html.erb:
<% form_tag '/sms', :method => :post do -%>
  <label>Enter the recipients mobile number:</label>
  <%= text_field_tag "recipient" %>
  <label>Enter your message:</label>
  <%= text_area_tag "message_text" %>
  <%= submit_tag "Send SMS" %>
<% end %>

# controllers/sms_controller.rb:
class SmsController < ApplicationController
def create
  sms = SMS.new(CLICKATELL_CONFIG)
  sms.create(params[:recipient], params[:message_text])
  flash[:notice] = "Message sent succesfully!"
  redirect_to :back
rescue Clickatell::API::Error => e
  flash[:error] = "Clickatell API error: #{e.message}"
  redirect_to :back
end
end

Hopefully, just like its described in the article.

I run the app and browse to: http://localhost:3000/sms/new

I enter the mobile no.: 447899999999 (I'm in the UK).

I enter the Message and click 'Send SMS'.

The app executes without an error, but no SMS is sent.  My Clickatell
credits are not decremented.

Any ideas on where I'm going wrong?  Has anyone managed to get this to
work using the Clickatell GEM?

Thanks in advance.

Any help would be greatly appreciated.

Kind Regards

Walter
Luke R. (Guest)
on 2008-12-29 23:16
Hi Walter,

Are you able to successfully send an SMS using the sms command line
utility bundled with the gem? Try enabling the library debug mode - you
should then be able to see the raw HTTP requests being sent.
David G. (Guest)
on 2010-11-08 00:38
Hi Walter,

did you manage to solve this issue? Did anyone knows how to solve this?

I'm facing exactly the same problem without any clue ...

Thanks!
This topic is locked and can not be replied to.