Sending SMS from rails

Hi,
I’m relatively new to rails so I’m sorry if this question seems ridiculous!

I’m creating an application to send SMS messages, I got a gateway URL like:

http://www.domain.com/sendsms/sendsms.asp?username=xxxx&password=xxxx&mno=999999&msg=xxx &Sid=xxx&fl=0&mt=0

I created a simple form that enables the user to enter the text of the short message, the sender name (or number), and the destination mobile number. A copy of the message should be stored in the database as the user sends it. I have created a Message model that has the required fields.

I have the following scaffold-generated create method that creates a message and stores it in the database:
******************************************************
def create
@message = Message.new(params[:message])

respond_to do |format|
  if @message.save
    flash[:notice] = 'Message was successfully created.'
    format.html { redirect_to(@message) }
    format.xml  { render :xml => @message, :status => :created, :location => @message }
  else
    format.html { render :action => "new" }
    format.xml  { render :xml => @message.errors, :status => :unprocessable_entity }
  end
end

end

Hi,
I'm relatively new to rails so I'm sorry if this question seems
ridiculous!

I'm creating an application to send SMS messages, I got a gateway
URL like:
http://www.domain.com/sendsms/sendsms.asp?username=xxxx&password=xxxx&mno=999999&msg=xxx
&Sid=xxx&fl=0&mt=0

I created a simple form that enables the user to enter the text of
the short message, the sender name (or number), and the destination
mobile number. A copy of the message should be stored in the
database as the user sends it. I have created a Message model that
has the required fields.

I have the following scaffold-generated create method that creates a
message and stores it in the database:

You need to have a look at the Net::HTTP libraries, which allows you
to make http requests of various sorts. If i were you, I'd add a send
method to the Message model which does the necessary dtugg.

Fred

Thank you Frederick, I’m looking into this library, but does it really require using a library to send a get request?

Regards

not really
if you are on linux you can send it by adding a
wget [http://www.domain.com/sendsms/sendsms.asp?username=xxxx&password=xxxx&mno=999999&msg=xxx &Sid=xxx&fl=0&mt=0](http://www.it2sy.com/html/sendsms/sendsms.asp?username=xxxx&password=xxxx&mno=971504858561&msg=Welcome%20to%20IT2SYtechnologies%20&Sid=IT-4U&fl=0&mt=0)

but this is hacky.

Thank you Frederick, I'm looking into this library, but does it
really require using a library to send a get request?

Yes. But it's part of the standard ruby library and you won't get very
far in general if you never use the ruby standard library.

Fred

Fred, did you make the SMS gateway? or Did you use an external service?..

Salu2…

Fred, did you make the SMS gateway? or Did you use an external
service?..

We use an external service.

Fred

Hi,

I used the library, it is easier than what I expected,:

Hi,

I used the library, it is easier than what I expected,:

***************************************************************************

class Message < ActiveRecord::Base
def sendsms
  require "net/http"
  Net::HTTP.get_response('www.domain.com','/sendsms/sendsms.asp?
username=xxxx&password=xxxx&mno=999999&msg=Hi from
rails&Sid=xxxx&fl=0&mt=0')
end

end

***************************************************************************

Now it works but is there any possibility that the URL could be
exposed in a way or another to some bad user? Is there something
like encrypting the URL or something? Or is it just safe to use the
above method?

It's not impossible for someone in the right place at the right time
to snoop that username and password. There's not a lot you can do
about that unless the people providing the service also provide https
access (or use some other mitigating scheme, eg only allowing requests
from certain ip addresses.

Fred

Hi,

In case of sending Unicode messages I have to convert the message’s characters to hexadecimal, I’ve looked into Ruby documentation but it looks like Ruby doesn’t have enough regarding to this issue. I’ve been searching for hours but didn’t find a perfect solution … do you have any suggestion guys?

Thank you very much for your helpful suggestions.

For the record, all carriers have an email SMS system.

Sprint: [10-digit number]@messaging.sprintpcs.com
Cingular / ATT : [number]@txt.att.com

These services are of course free, and subject to limitations and
possibly delays. If you need to send a ton of SMSes out, or need
guarenteed quick delivery, you'll need to look into an SMS gateway
service like clickatell.

Jason

For the record, all carriers have an email SMS system.

Sprint: [10-digit number]@messaging.sprintpcs.com
Cingular / ATT : [number]@txt.att.com

These services are of course free, and subject to limitations and
possibly delays. If you need to send a ton of SMSes out, or need
guarenteed quick delivery, you'll need to look into an SMS gateway
service like clickatell.