1
我創建使用Twilio公司的Java lib中,像這樣的電話:解析Twilio statuscallback電話/會議活動
PhoneNumber phoneNumberTo = new PhoneNumber(to);
PhoneNumber phoneNumberFrom = new PhoneNumber(from);
com.twilio.rest.api.v2010.account.Call call = new CallCreator(phoneNumberTo, phoneNumberFrom, URI.create(twimlUrl))
.setStatusCallback(URI.create(twStatusCallbackUrl))
.setStatusCallbackEvent(Arrays.asList(
com.twilio.rest.api.v2010.account.Call.Event.ANSWERED.toString(),
com.twilio.rest.api.v2010.account.Call.Event.COMPLETED.toString(),
com.twilio.rest.api.v2010.account.Call.Event.INITIATED.toString(),
com.twilio.rest.api.v2010.account.Call.Event.RINGING.toString()))
.create(this.client);
我得到調用事件application/x-www-form-urlencoded
。有沒有一種最佳實踐方式將發送的表單數據解析爲某種Twilio調用事件對象?通過Twilio發送的狀態
例子:
START TIME =09-Jan-2017 16:00:16
requestURI=/api/calls/12345/
authType=null
characterEncoding=UTF-8
contentLength=591
contentType=application/x-www-form-urlencoded; charset=utf-8
contextPath=
header=accept=*/*
header=cache-control=max-age=259200
header=content-length=591
header=content-type=application/x-www-form-urlencoded; charset=utf-8
header=host=api.example.com
header=x-twilio-signature=BLAH/BLAH
header=user-agent=TwilioProxy/1.1
header=connection=close
locale=en_US
method=POST
parameter=Called=+44123456789
parameter=ToState=London
parameter=CallerCountry=GB
parameter=Direction=outbound-api
parameter=Timestamp=Mon, 09 Jan 2017 16:00:16 +0000
parameter=CallbackSource=call-progress-events
parameter=CallerState=London
parameter=ToZip=
parameter=SequenceNumber=3
parameter=CallSid=BLAHBLAH
parameter=To=+44123456789
parameter=CallerZip=
parameter=ToCountry=GB
parameter=ApiVersion=2010-04-01
parameter=CalledZip=
parameter=CalledCity=
parameter=CallStatus=completed
parameter=Duration=1
parameter=From=+44123456789
parameter=CallDuration=5
parameter=AccountSid=BLAHBLAH
parameter=CalledCountry=GB
parameter=CallerCity=
parameter=Caller=+44123456789
parameter=FromCountry=GB
parameter=ToCity=
parameter=FromCity=
parameter=CalledState=London
parameter=FromZip=
parameter=FromState=London
pathInfo=null
protocol=HTTP/1.1
queryString=null
remoteAddr=X.X.X.X
remoteHost=X.X.X.X
remoteUser=null
requestedSessionId=null
scheme=http
serverName=api.example.com
serverPort=8082
servletPath=/api/calls/12345/
isSecure=false
謝謝,但我相信這只是打電話(v5)的棄用方式。這正是我上面所做的,也沒有說明如何處理回來的回調事件。希望API攔截statuscallback事件,並保持內部模型的更新。不要以爲是這樣? –