Last active
July 28, 2017 01:32
-
-
Save bash0C7/5425124 to your computer and use it in GitHub Desktop.
Twilio ワン切りサンプル
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
「Twilio ワン切り」でぐぐったらここへと。そして書いた人がbash0C7さんとは!(゚д゚lll)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
なおしました!ご指摘ありがとうございます:+1: