You are here

function sms_txtlocal_receive_receipt in SMS Framework 6

Receive a message send receipt from txtlocal

Will generate an $options array with the following variables:

  • reference - A message reference code, if set on message send.
  • gateway_status - A txtlocal message status code.
  • gateway_status_text - A text string associated with the gateway_status.
  • customID - Same as reference. txtlocal param: 'customID'

See http://www.txtlocal.co.uk/sms-gateway-demo.php

1 string reference to 'sms_txtlocal_receive_receipt'
sms_txtlocal_menu in modules/sms_txtlocal/sms_txtlocal.module
Implement hook_menu()

File

modules/sms_txtlocal/sms_txtlocal.module, line 381
Txtlocal gateway module for Drupal SMS Framework. Outbound+Inbound

Code

function sms_txtlocal_receive_receipt() {
  if ($config['sms_txtlocal_receipts']) {
    $number = array_key_exists('number', $_REQUEST) ? $_REQUEST['number'] : NULL;
    $reference = array_key_exists('customID', $_REQUEST) ? $_REQUEST['customID'] : NULL;
    $gw_msg_status_code = array_key_exists('status', $_REQUEST) ? $_REQUEST['status'] : NULL;
    $options = array();

    // Define raw gateway receipt call parameters
    $options['gateway_params'] = array();
    if (array_key_exists('number', $_REQUEST) && !empty($_REQUEST['number'])) {
      $options['gateway_params']['number'] = $_REQUEST['number'];
    }
    if (array_key_exists('customID', $_REQUEST) && !empty($_REQUEST['customID'])) {
      $options['gateway_params']['customID'] = $_REQUEST['customID'];
    }

    // Define message receiver and reference in options array
    $options['reference'] = $reference;

    // Get framework message status code and Clickatell status text
    $status = sms_txtlocal_map_message_status_code($gw_msg_status_code);
    $gw_msg_status_codes = sms_txtlocal_message_status_codes();
    $gw_msg_status_text = $gw_msg_status_codes[$gw_msg_status_code];

    // Define gateway-specific status (code) and text (success/error message)
    $options['gateway_message_status'] = $gw_msg_status_code;
    $options['gateway_message_status_text'] = $gw_msg_status_text;

    // Invoke the SMS Framework receipt handler
    sms_receipt($number, $reference, $status, $options);
  }
}