Module Writers Guide to use SMS API
Steps:
- Add your modules Main keyword in this file $global['approot'].“/mod/msg/lib_sms_keywords.inc”
- Currently all keywords are provided in “lowercase”
- global $sms_list_keywords; is the array which stores the keywords.
- Numeric codes are “keys” of the array.
- Any specific error message you need to add goes here $global['approot'].“/mod/msg/lib_sms_errors.inc”
- For error handling over SMS this file needs to be included
- Contains list of error codes and corresponding Error SMS to be sent
- function _shn_msg_sms_error_code($error_code) results the Error SMS Text upon passing the error code as argument
- Module specific functions and their action keywords should be written in this file $global['approot'].“/mod/msg/lib_sms_handler.inc”
- Main file that contains functions for actions specific to keyword. Module functions go here.
- function _shn_msg_sms_action($parsed_sms, $sender_phone_number) the “/mod/msg/lib_msg.inc” passes the incoming text to this function
- Module actions go here in the following format:
- if ( ( “help” ==$parsed_sms[0]) || ( “ 911 ” == $parsed_sms[0])){
- $parsed_sms[0] → contains the keyword. This logic checks for both “word” and “numeric” codes and then proceeds further.
- 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.
- Ideally, module functions should return values which should be parsed as normal plain text to form the outgoing SMS.
- Function names are written as “_shn_msg_sms_help” interpreted as shn_msg is Sahana standard, SMS for SMS and the HELP keyword.
- 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”