Alex Avlonitis Alex Avlonitis - 1 year ago 254
Ruby Question

Amazon SNS with ruby, simple sms message

I'm trying to send a simple sms from ruby directly to a phone number with the SNS service.

require 'aws-sdk'
sns = 'my_region', access_key_id: 'my_id', secret_access_key: 'mykey')
sns.publish({phone_number: 'my_number', message: 'test message'})

but i get
ArgumentError: unexpected value at params[:phone_number]

Answer Source

The following example using a fictional UK mobile phone number in E.164 format works for me, are you sure you're passing phone_number in a string?

require 'aws-sdk'

sns =
#=> #<Aws::SNS::Client>
sns.publish(phone_number: '+447911123456', message: 'test message')
#=> #<struct Aws::SNS::Types::PublishResponse...>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download