将呼叫者 ID 动态设置为 Twilio 号码
dynamically set caller id to Twilio number
是否可以在 twilio 中即时设置来电显示。我知道您可以通过验证来自 twilio 的号码来设置来电显示,但我如何才能实现以下用例 -
我有 5 个不同的号码和一个我用来给用户打电话的 twilio 号码,现在我的用例是我需要根据某些条件动态地将这 5 个号码中的呼叫者 ID 设置为 twilio 号码,例如.setCallerId()
.
更新 1:
我正在使用以下代码发起呼叫 -
Call call = Call
.creator(new PhoneNumber(to), new PhoneNumber(from),
new URI(url)).create();
这里url我路过,实际上是为用户播放IVR消息。
Say say = new Say.Builder(announcement).voice(Say.Voice.WOMAN)
.language(Language.EN_US).loop(4).build();
Pause pause = new Pause.Builder().length(1).build();
voiceResponse = new VoiceResponse.Builder()
.say(say)
.pause(pause)
.build();
此处为 Twilio 开发人员布道师。
您只能将通话中的来电显示设置为您在 Twilio 中购买的号码或您已验证的号码。
当您使用 TwiML 将 Twilio 呼叫连接到另一个呼叫者时,您可以 set the caller ID using an attribute on the <Dial>
。例如:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial callerId="+15551112222">
<Number>+15558675310</Number>
</Dial>
</Response>
在 Java 中,看起来有点像:
import com.twilio.twiml.voice.Dial;
import com.twilio.twiml.voice.Number;
import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.TwiMLException;
public class Example {
public static void main(String[] args) {
Number number = new Number.Builder("+15558675310").build();
Dial dial = new Dial.Builder().callerId("+15551112222").number(number)
.build();
VoiceResponse response = new VoiceResponse.Builder().dial(dial).build();
try {
System.out.println(response.toXml());
} catch (TwiMLException e) {
e.printStackTrace();
}
}
}
是否可以在 twilio 中即时设置来电显示。我知道您可以通过验证来自 twilio 的号码来设置来电显示,但我如何才能实现以下用例 -
我有 5 个不同的号码和一个我用来给用户打电话的 twilio 号码,现在我的用例是我需要根据某些条件动态地将这 5 个号码中的呼叫者 ID 设置为 twilio 号码,例如.setCallerId()
.
更新 1:
我正在使用以下代码发起呼叫 -
Call call = Call
.creator(new PhoneNumber(to), new PhoneNumber(from),
new URI(url)).create();
这里url我路过,实际上是为用户播放IVR消息。
Say say = new Say.Builder(announcement).voice(Say.Voice.WOMAN)
.language(Language.EN_US).loop(4).build();
Pause pause = new Pause.Builder().length(1).build();
voiceResponse = new VoiceResponse.Builder()
.say(say)
.pause(pause)
.build();
此处为 Twilio 开发人员布道师。
您只能将通话中的来电显示设置为您在 Twilio 中购买的号码或您已验证的号码。
当您使用 TwiML 将 Twilio 呼叫连接到另一个呼叫者时,您可以 set the caller ID using an attribute on the <Dial>
。例如:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial callerId="+15551112222">
<Number>+15558675310</Number>
</Dial>
</Response>
在 Java 中,看起来有点像:
import com.twilio.twiml.voice.Dial;
import com.twilio.twiml.voice.Number;
import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.TwiMLException;
public class Example {
public static void main(String[] args) {
Number number = new Number.Builder("+15558675310").build();
Dial dial = new Dial.Builder().callerId("+15551112222").number(number)
.build();
VoiceResponse response = new VoiceResponse.Builder().dial(dial).build();
try {
System.out.println(response.toXml());
} catch (TwiMLException e) {
e.printStackTrace();
}
}
}