本文整理汇总了Java中com.twilio.sdk.verbs.TwiMLResponse.append方法的典型用法代码示例。如果您正苦于以下问题:Java TwiMLResponse.append方法的具体用法?Java TwiMLResponse.append怎么用?Java TwiMLResponse.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.twilio.sdk.verbs.TwiMLResponse
的用法示例。
在下文中一共展示了TwiMLResponse.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: service
import com.twilio.sdk.verbs.TwiMLResponse; //导入方法依赖的package包/类
@Override
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
String query = request.getParameter("Body");
if (Strings.isNullOrEmpty(query)) {
// Empty request
return;
}
String openApiResponse = sendRequestToApiAi(query, request.getParameterMap());
TwiMLResponse twiml = new TwiMLResponse();
Message message = new Message(openApiResponse);
try {
twiml.append(message);
} catch (TwiMLException e) {
LOGGER.error(e.getMessage());
}
response.setContentType("application/xml");
response.getWriter().print(twiml.toXML());
}
示例2: service
import com.twilio.sdk.verbs.TwiMLResponse; //导入方法依赖的package包/类
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
// Create a dict of people we know.
HashMap<String, String> people = new HashMap<String, String>();
people.put("+14158675308", "Curious George");
people.put("+14158675310", "Boots");
people.put("+14158675311", "Virgil");
// if the sender is known, then greet them by name
String fromNumber = request.getParameter("From");
String name = fromNumber != null && people.get(fromNumber) != null
? people.get(fromNumber)
: "Monkey";
TwiMLResponse twiml = new TwiMLResponse();
try {
twiml.append(new Say(String.format("Hello! %s", name)));
twiml.append(new Sms(String.format("%s, thanks for the call!", name)));
} catch (TwiMLException e) {
e.printStackTrace();
}
response.setContentType("application/xml");
response.getWriter().print(twiml.toXML());
}
示例3: service
import com.twilio.sdk.verbs.TwiMLResponse; //导入方法依赖的package包/类
@Override
public void service(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
final TwiMLResponse twiml = new TwiMLResponse();
final Enqueue enqueue = new Enqueue();
enqueue.setWorkflowSid("WW0123456789abcdef0123456789abcdef");
enqueue.setWaitUrl("/hold_music.php");
enqueue.setAction("/post_bridge_survey.php");
final com.twilio.sdk.verbs.Task task = new com.twilio.sdk.verbs.Task("{\"account_number\":\"12345abcdef\"}");
try {
enqueue.append(task);
twiml.append(enqueue);
} catch (final TwiMLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return twiml.toXML();
}
示例4: service
import com.twilio.sdk.verbs.TwiMLResponse; //导入方法依赖的package包/类
@Override
public void service(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
final TwiMLResponse twiml = new TwiMLResponse();
final Enqueue enqueue = new Enqueue();
enqueue.setWorkflowSid("WW0123456789abcdef0123456789abcdef");
final com.twilio.sdk.verbs.Task task = new com.twilio.sdk.verbs.Task("{\"account_number\":\"12345abcdef\"}");
task.setPriority(5);
task.setTimeout(200);
try {
enqueue.append(task);
twiml.append(enqueue);
} catch (final TwiMLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return twiml.toXML();
}
示例5: doPost
import com.twilio.sdk.verbs.TwiMLResponse; //导入方法依赖的package包/类
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// Create a TwiML builder object
TwiMLResponse twiml = new TwiMLResponse();
// Get the city from the incoming call (if available)
String fromCity = request.getParameter("FromCity");
if (fromCity == null) {
fromCity = "home slice";
}
try {
Say message = new Say(String.format("Never gonna give you up, %s!", fromCity));
message.setVoice("alice");
Play song = new Play("https://demo.twilio.com/docs/classic.mp3");
twiml.append(message);
twiml.append(song);
} catch (TwiMLException e) {
e.printStackTrace();
}
// Render TwiML as XML
response.setContentType("text/xml");
response.getWriter().print(twiml.toXML());
}
示例6: doPost
import com.twilio.sdk.verbs.TwiMLResponse; //导入方法依赖的package包/类
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
// Create a TwiML response and add our friendly message.
TwiMLResponse twiml = new TwiMLResponse();
Gather gather = new Gather();
gather.setNumDigits(1);
try {
gather.append(new Say("For sales, press 1. For support, press 2."));
twiml.append(gather);
twiml.append(new Redirect("/voice"));
} catch (TwiMLException e) {
throw new RuntimeException(e);
}
response.setContentType("application/xml");
response.getWriter().print(twiml.toXML());
}
示例7: main
import com.twilio.sdk.verbs.TwiMLResponse; //导入方法依赖的package包/类
public static void main(String[] args) {
// Create a TwiML builder object
TwiMLResponse twiml = new TwiMLResponse();
try {
Message message = new Message();
Body body = new Body("Hello friend");
Media media = new Media("https://demo.twilio.com/owl.png");
message.append(body);
message.append(media);
twiml.append(message);
} catch (TwiMLException e) {
e.printStackTrace();
}
System.out.println(twiml.toXML());
}
示例8: service
import com.twilio.sdk.verbs.TwiMLResponse; //导入方法依赖的package包/类
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
// Create a TwiML response and add our friendly message.
TwiMLResponse twiml = new TwiMLResponse();
Gather gather = new Gather();
gather.setNumDigits(1);
try {
gather.append(new Say("For sales, press 1. For support, press 2."));
twiml.append(gather);
twiml.append(new Redirect("/voice"));
} catch (TwiMLException e) {
throw new RuntimeException(e);
}
response.setContentType("application/xml");
response.getWriter().print(twiml.toXML());
}
示例9: service
import com.twilio.sdk.verbs.TwiMLResponse; //导入方法依赖的package包/类
@Override
public void service(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
final TwiMLResponse twiml = new TwiMLResponse();
final Enqueue enqueue = new Enqueue();
enqueue.setWorkflowSid("WW0123456789abcdef0123456789abcdef");
final com.twilio.sdk.verbs.Task task = new com.twilio.sdk.verbs.Task("{\"account_number\":\"12345abcdef\"}");
try {
enqueue.append(task);
twiml.append(enqueue);
} catch (final TwiMLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return twiml.toXML();
}
示例10: main
import com.twilio.sdk.verbs.TwiMLResponse; //导入方法依赖的package包/类
public static void main(String[] args) {
TwiMLResponse twiml = new TwiMLResponse();
try {
Say say = new Say("Welcome to Twilio, please tell us why you're calling");
Gather gather = new Gather();
gather.setAction("/completed");
gather.set("input", "speech");
gather.append(say);
twiml.append(gather);
} catch (TwiMLException e) {
e.printStackTrace();
}
System.out.println(twiml.toXML());
}
示例11: service
import com.twilio.sdk.verbs.TwiMLResponse; //导入方法依赖的package包/类
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
String recordingUrl = request.getParameter("RecordingUrl");
TwiMLResponse twiml = new TwiMLResponse();
if (recordingUrl != null) {
try {
twiml.append(new Say("Listen to your recorded message."));
twiml.append(new Play(recordingUrl));
twiml.append(new Say("Goodbye"));
} catch (TwiMLException e) {
e.printStackTrace();
}
} else {
response.sendRedirect("/twiml");
return;
}
response.setContentType("application/xml");
response.getWriter().print(twiml.toXML());
}
示例12: doPost
import com.twilio.sdk.verbs.TwiMLResponse; //导入方法依赖的package包/类
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// Create a TwiML builder object
TwiMLResponse twiml = new TwiMLResponse();
try {
Say message = new Say("hello world!");
message.setVoice("alice");
twiml.append(message);
} catch (TwiMLException e) {
e.printStackTrace();
}
// Render TwiML as XML
response.setContentType("text/xml");
response.getWriter().print(twiml.toXML());
}
示例13: service
import com.twilio.sdk.verbs.TwiMLResponse; //导入方法依赖的package包/类
@Override
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException,
ServletException {
String fromNumber = request.getParameter("From");
String body = request.getParameter("Body");
String message = String.format("Hello, %s, you said %s", fromNumber, body);
TwiMLResponse twiml = new TwiMLResponse();
Message sms = new Message(message);
try {
twiml.append(sms);
} catch (TwiMLException e) {
throw new ServletException("Twilio error", e);
}
response.setContentType("application/xml");
response.getWriter().print(twiml.toXML());
}
示例14: service
import com.twilio.sdk.verbs.TwiMLResponse; //导入方法依赖的package包/类
@Override
public void service(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String fromNumber = request.getParameter("From");
String body = request.getParameter("Body");
String message = String.format("Hello, %s, you said %s", fromNumber, body);
TwiMLResponse twiml = new TwiMLResponse();
Message sms = new Message(message);
try {
twiml.append(sms);
} catch (TwiMLException e) {
throw new ServletException("Twilio error", e);
}
response.setContentType("application/xml");
response.getWriter().print(twiml.toXML());
}
示例15: service
import com.twilio.sdk.verbs.TwiMLResponse; //导入方法依赖的package包/类
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
TwiMLResponse twiml = new TwiMLResponse();
Message message = new Message("The Robots are coming! Head for the hills!");
try {
twiml.append(message);
} catch (TwiMLException e) {
e.printStackTrace();
}
response.setContentType("application/xml");
response.getWriter().print(twiml.toXML());
}