You are here

function sms_clickatell_receive_message in SMS Framework 6

Receive an SMS message and pass it into the SMS Framework

Will generate an $options array with the following variables: receiver - The destination MSISDN number. Clickatell param: 'to' reference - The message ID code that refers to a message originally sent with the 'expectreply' or 'mo' parameter. Clickatell param: 'moMsgId' For raw gateway params see Clickatell_two-way_technical_guide.pdf page 9.

I have neglected the Clickatell 'timestamp' param because it is passed in non-UTC timezone and is in MySQL format. It is more useful to capture a timestamp in your hook_sms_incoming() function.

1 string reference to 'sms_clickatell_receive_message'
sms_clickatell_menu in modules/sms_clickatell/sms_clickatell.module
Implement hook_menu()

File

modules/sms_clickatell/sms_clickatell.module, line 394
Clickatell gateway module for Drupal SMS Framework. Outbound+Inbound+Receipts

Code

function sms_clickatell_receive_message() {
  $number = $_REQUEST['from'];
  $message = $_REQUEST['text'];
  $options = array();

  // Define raw gateway response parameters
  $options['gateway_params'] = array();
  if (array_key_exists('to', $_REQUEST) && !empty($_REQUEST['to'])) {
    $options['gateway_params']['to'] = $_REQUEST['to'];
  }
  if (array_key_exists('api_id', $_REQUEST) && !empty($_REQUEST['api_id'])) {
    $options['gateway_params']['api_id'] = $_REQUEST['api_id'];
  }
  if (array_key_exists('moMsgId', $_REQUEST) && !empty($_REQUEST['moMsgId'])) {
    $options['gateway_params']['moMsgId'] = $_REQUEST['moMsgId'];
  }

  // Define message receiver and reference in options array
  $options['receiver'] = array_key_exists('to', $_REQUEST) ? $_REQUEST['to'] : '';
  $options['reference'] = array_key_exists('moMsgId', $_REQUEST) ? $_REQUEST['moMsgId'] : '';
  sms_incoming($number, $message, $options);
}