12
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

TwilioでSMSを送ってみよう。

Last updated at Posted at 2013-12-25

Twilioを使えば簡単にSMSの送信が可能になる。

まず、Twilioから提供しているgemをインストールします。
gem install twilio-ruby

その他、Twilioはライブラリを提供している。
PHP, Python, .NET, JAVAなど、様々なプログラミング言語に対応されているので、各自好きな言語のライブラリをダウンロードすればより簡単にTwilioを楽しむことが可能になる。
詳細はこちら。
https://jp.twilio.com/docs/libraries

※ 注意
Twilio for KDDI Web Communicationsでは基本「050」番号を提供しているが、SMSに関してはアメリカ番号を使うことになっている。

下記のように短いコードを書くだけでSMSの送信が可能になる!

twilio-sms.rb
# encoding: utf-8
require 'rubygems'
require 'twilio-ruby'
 
account_sid = '<Account SID>'
auth_token = '<Auth Token>'
 
client = Twilio::REST::Client.new(account_sid, auth_token)
 
from = "+141xxxxxxxx"
to = "+8180xxxxxxxx"
 
client.account.sms.messages.create(
:from => from,
:to => to,
:body => 'Twilio for KDDI Web CommunicationsからSMSの提供を開始します。簡単でしょう〜'
)

puts "SMSメッセージ送信完了。"

12
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?