i followed the tutorial at https://www.twilio.com/docs/quickstart/java/twiml/record-caller-leave-message and am getting stuck at the recording. the twilio logs indicate "Problem accessing /handle-key. with a 404." i am set up with localtunnel, and i configured my number to point to the http://43v8.localtunnel.com/myapp/twilio url. the greeting works, i only have trouble when picking 1 or 2 on my dial pad. i would appreciate any help.
问问题
156 次
1 回答
0
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());
}
}
于 2016-05-09T22:59:03.770 回答