gpt4 book ai didi

java - twilio教程问题

转载 作者:行者123 更新时间:2023-12-01 04:59:41 24 4
gpt4 key购买 nike

我按照 https://www.twilio.com/docs/quickstart/java/twiml/record-caller-leave-message 上的教程进行操作我被困在录音中。 twilio 日志显示“访问/handle-key 时出现问题。出现 404”。我设置了本地隧道,并将我的号码配置为指向 http://43v8.localtunnel.com/myapp/twilio网址。问候语有效,我只在拨号盘上选择 1 或 2 时遇到麻烦。我将不胜感激任何帮助。

最佳答案

TwilioHandleRecordingServlet:

package com.twilio;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;

import com.twilio.sdk.verbs.TwiMLResponse;
import com.twilio.sdk.verbs.TwiMLException;
import com.twilio.sdk.verbs.Say;
import com.twilio.sdk.verbs.Play;
import com.twilio.sdk.verbs.Dial;

public class TwilioHandleRecordingServlet extends HttpServlet {

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("Thanks for howling... take a listen to what you howled."));
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());
}
}

关于java - twilio教程问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13552949/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com