this tropo code in ruby want to convert in php
This is tropo code and I want to convert it to php code. It is used in a
webapi of tropo. It will work as a connector between phono and tropo. I
have to made a web to phone app with two way communication.
transfer $currentCall.getHeader("x-numbertodial")
require "net/http"
Thread.new do
sleep 600 # Note: Sleep is in seconds so 600 = 10 minutes
http = Net::HTTP.new "api.tropo.com"
request = Net::HTTP::Get.new
"/1.0/sessions/#{$currentCall.sessionId}/signals?action=signal&value=limitreached"
response = http.request request
end
say "hold please while we transfer your call."
transfer $currentCall.getHeader("x-numbertodial"), :allowsignals =>
"limitreached"
say "your limit has been reached."
phone = $currentCall.getHeader "x-numbertodial"
blocked = [
/^+?1?8[024]9/,
/^+?1?26[48]/,
/^+?1?24[26]/,
/^+?1?34[05]/,
/^+?1?[62]84/,
/^+?1?67[10]/,
/^+?1?78[47]/,
/^+?1?8[024]9/,
/^+?1?86[89]/,
/^+?1?441/,
/^+?1?473/,
/^+?1?664/,
/^+?1?649/,
/^+?1?721/,
/^+?1?758/,
/^+?1?767/,
/^+?1?876/,
/^+?1?939/
]
block_call = blocked.any? { |x| phone =~ x }
if block_call
say "calls to this area code are blocked."
else
say "hold please while we transfer your call."
transfer phone, :allowsignals => "limitreached"
say "your limit has been reached."
end
No comments:
Post a Comment