Module Writers Guide to use SMS API

Steps:

  1. Add your modules Main keyword in this file $global['approot'].“/mod/msg/lib_sms_keywords.inc”
    1. Currently all keywords are provided in “lowercase”
    2. global $sms_list_keywords; is the array which stores the keywords.
    3. Numeric codes are “keys” of the array.
  2. Any specific error message you need to add goes here $global['approot'].“/mod/msg/lib_sms_errors.inc”
    1. For error handling over SMS this file needs to be included
    2. Contains list of error codes and corresponding Error SMS to be sent
    3. function _shn_msg_sms_error_code($error_code) results the Error SMS Text upon passing the error code as argument
  3. Module specific functions and their action keywords should be written in this file $global['approot'].“/mod/msg/lib_sms_handler.inc”
    1. Main file that contains functions for actions specific to keyword. Module functions go here.
    2. function _shn_msg_sms_action($parsed_sms, $sender_phone_number) the “/mod/msg/lib_msg.inc” passes the incoming text to this function
    3. Module actions go here in the following format:
      1. if ( ( “help” ==$parsed_sms[0]) || ( “ 911 ” == $parsed_sms[0])){
      2. $parsed_sms[0] → contains the keyword. This logic checks for both “word” and “numeric” codes and then proceeds further.
      3. Module functions should not output any HTML or print any text as they do in case of a browser. It might result in malfunction of SMS Formation for output.
      4. Ideally, module functions should return values which should be parsed as normal plain text to form the outgoing SMS.
      5. Function names are written as “_shn_msg_sms_help” interpreted as shn_msg is Sahana standard, SMS for SMS and the HELP keyword.
      6. Outgoing SMS is sent using the function shn_msg_plugin_send_sm($recipients, $sms_text) which is a plugin dependent function → include_once $global['approot'].“/mod/msg/plugins/”.“$plugin_name”.“/handler_”.“$plugin_name”.“.inc”

Navigation
QR Code
QR Code dev:gsoc_2008_msg_sms_module_guide (generated for current page)