我们目前正在测试Twilio Voice API并能够加入呼叫和录音,但是15秒后呼叫正在断开连接。在呼叫者断开呼叫之前,我们如何录制呼叫?以下是用例:
期望Twilio应该能够记录通话语音,直到用户A挂断电话。任何帮助将不胜感激。以下是代码片段:
import com.twilio.Twilio;
import com.twilio.http.HttpMethod;
import com.twilio.rest.api.v2010.account.Call;
import com.twilio.type.PhoneNumber;
public class MakeCall {
public static final String ACCOUNT_SID = "xxxxxxx";
public static final String AUTH_TOKEN = "yyyyyyyy";
public static void main(String[] args) throws Exception {
makeCalls("222-333-4444");
}
private static void makeCalls(String phoneNumber) throws Exception {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
List<String> callbackEvents = Arrays.asList("initiated", "ringing", "answered", "completed");
Call call = Call
.creator(new PhoneNumber(phoneNumber), new PhoneNumber("+12343453456"),
new URI("http://0ecefc72.ngrok.io/voice.xml"))
//.setMethod(HttpMethod.GET).setStatusCallback("https://www.myapp.com/events")
.setRecord(true)
.create();
//.setStatusCallbackMethod(HttpMethod.POST).setStatusCallbackEvent(callbackEvents).create();
System.out.println(call.getSid());
}
}
最佳, 亚当