2
0

api.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
  3. * Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
  4. *
  5. * Version: MPL 1.1
  6. *
  7. * The contents of this file are subject to the Mozilla Public License Version
  8. * 1.1 (the "License"); you may not use this file except in compliance with
  9. * the License. You may obtain a copy of the License at
  10. * http://www.mozilla.org/MPL/
  11. *
  12. * Software distributed under the License is distributed on an "AS IS" basis,
  13. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  14. * for the specific language governing rights and limitations under the
  15. * License.
  16. *
  17. * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
  18. *
  19. * The Initial Developer of the Original Code is
  20. * Anthony Minessale II <anthm@freeswitch.org>
  21. * Portions created by the Initial Developer are Copyright (C)
  22. * the Initial Developer. All Rights Reserved.
  23. *
  24. * Contributor(s):
  25. *
  26. * Anthony Minessale II <anthm@freeswitch.org>
  27. *
  28. *
  29. * api.js Demo javascript FSAPI Interface
  30. *
  31. * To use this script:
  32. * 1) Put it in $prefix/scripts. (eg /usr/local/freeswitch/scripts)
  33. * 2) Load mod_xml_rpc and point a browser to your FreeSWITCH machine.
  34. * http://your.freeswitch.box:8080/api/jsapi?api.js
  35. */
  36. /* Other possible js commands */
  37. //env = request.dumpENV("text");
  38. //xmlenv = new XML(request.dumpENV("xml"));
  39. //request.addHeader("js-text", "You were in a javascript script");
  40. if (session) {
  41. request.write("Don't call me from the dialplan silly! I'm a web interface today.\n");
  42. consoleLog("err", "Invalid usage!\n");
  43. exit();
  44. }
  45. request.write("Content-Type: text/html\n\n");
  46. request.write("<title>FreeSWITCH Command Portal</title>");
  47. request.write("<h2>FreeSWITCH Command Portal</h2>");
  48. request.write("<form method=post><input name=command size=40> ");
  49. request.write("<input type=submit value=\"Execute\">");
  50. request.write("</form><hr noshade size=1><br>");
  51. if ((command = request.getHeader("command"))) {
  52. cmd_list = command.split(" ");
  53. cmd = cmd_list.shift();
  54. args = cmd_list.join(" ");
  55. if ((reply = apiExecute(cmd, args))) {
  56. request.write("<br><B>Command Result</b><br><pre>" + reply + "\n</pre>");
  57. }
  58. }