Skip to content

Instantly share code, notes, and snippets.

@bash0C7
Last active July 28, 2017 01:32
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bash0C7/5425124 to your computer and use it in GitHub Desktop.
Save bash0C7/5425124 to your computer and use it in GitHub Desktop.
Twilio ワン切りサンプル
require 'twilio-ruby'
#twilio account
twilio_account_sid = 'XXXXXX'
auth_token = 'XXXXXX'
from_number = '+81XXXXX' #コール元(twilioの電話番号)
to_number = '+81XXXXX' #コール先
url = 'http://example.com' #通話を接続する時に使う完全修飾 URL です。 着信通話を処理するために、電話番号に URL をセットするのと同じです。 詳細は、後述の URL パラメーター のセクションを参照してください。 https://jp.twilio.com/docs/api/rest/making-calls
calling_time = 8 #コールする時間
client = Twilio::REST::Client.new(twilio_account_sid, auth_token)
account = client.account
call = account.calls.create({:from => from_number, :to => to_number, :url => url})
#calling_time過ぎたら切る
call.tap {|t| sleep(calling_time)}.cancel
@bash0C7
Copy link
Author

bash0C7 commented Apr 22, 2013

なおしました!ご指摘ありがとうございます:+1:

Copy link

ghost commented Nov 5, 2015

「Twilio ワン切り」でぐぐったらここへと。そして書いた人がbash0C7さんとは!(゚д゚lll)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment