【问题标题】:twilio tutorial problemstwilio 教程问题
【发布时间】:2012-11-25 16:24:55
【问题描述】:

我按照https://www.twilio.com/docs/quickstart/java/twiml/record-caller-leave-message 上的教程进行操作,但在录制过程中卡住了。 twilio 日志指示“访问 /handle-key 时出现问题。使用 404。”我设置了 localtunnel,并将我的号码配置为指向http://43v8.localtunnel.com/myapp/twilio url。问候有效,我只有在拨号盘上选择 1 或 2 时遇到问题。我将不胜感激。

【问题讨论】:

    标签: java twilio


    【解决方案1】:

    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());
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2013-09-10
      • 2011-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-16
      • 2021-02-15
      • 2019-09-06
      • 1970-01-01
      相关资源
      最近更新 更多