Echo example in Scala
History Key
- New content
Removed content
Recent Versions
Choose two versions to compare, or click the link to view it.
Here's a simple echo example, written as a Java Servlet in Scala(full source, build instructions):Scala:
class EchoServlet extends HttpServlet {
override def doPost(req:HttpServletRequest, resp:HttpServletResponse) {
// Extract details sent from Taykt to this web hook:
val from = req.getParameter("pid")
val mo_msg = req.getParameter("text")
// Compose and send the response:
resp.setContentType("text/plain")
resp.setCharacterEncoding("utf-8");
resp.getWriter().println( from + " sent " + mo_msg )
}
}You can try this particular service out with the web hook URL of:
http://taykt-demo.appspot.com/echo
Example call to the web hook:
$ curl http://taykt-demo.appspot.com/echo -X POST -d text="this is my message" -d pid="abc123"
...which produces:
abc123 sent this is my message
We also provide a second example which texts back the time in a given location:
$ curl http://taykt-demo.appspot.com/date -X POST -d text="demodate Sydney" It's 2009-09-17 06:30 in Eastern Standard Time (New South Wales)