SMS Gateway Hub API

Last updated on
30 April 2025

The SMS Gateway Hub API allows you to send SMS using SMSGatewayHub with Drupal. You can send promotional SMS to users using the service.
Contents:

Programmatically send SMS

/**
 * Send SMS.
 *
 * @param string $numbers
 *   Single number or comma separated numbers.
 * @param string $message
 *   SMS message.
 * @param int $flash
 *   0 or 1 indicating whether this SMS should be sent as flash message.
 * @param int $transactional
 *   0 or 1 indicating whether this SMS should be sent as transactional message.
 * @param int $scheduled_time
 *   Timestamp indicating when the message will be sent. If 0 then scheduled
 *   time is disabled.
 *
 * @return string
 *   Unique message id or failed response.
 */
smsgatewayhub_send_sms($numbers, $message, $flash = 0, $transactional = 0, $scheduled_time = 0);

API hooks

Hook called before sending SMS

/**
 * Do something before sending SMS.
 *
 * This hook is invoked after hook_smsgatewayhub_sms_alter().
 *
 * @param string $numbers
 *   Single number or comma separated numbers.
 * @param string $message
 *   SMS message.
 * @param int $flash
 *   0 or 1 indicating whether this SMS should be sent as flash message.
 * @param int $transactional
 *   0 or 1 indicating whether this SMS should be sent as transactional message.
 * @param int $scheduled_time
 *   Timestamp indicating when the message will be sent. If 0 then scheduled
 *   time is disabled.
 */
function hook_smsgatewayhub_before_send_sms($numbers, $message, $flash, $transactional, $scheduled_time) {
  // Do something here.
}

Hook called after sending SMS

/**
 * Do something after SMS is sent.
 *
 * @param string $numbers
 *   Single number or comma separated numbers.
 * @param string $message
 *   SMS message.
 * @param int $flash
 *   0 or 1 indicating whether this SMS should be sent as flash message.
 * @param int $transactional
 *   0 or 1 indicating whether this SMS should be sent as transactional message.
 * @param int $scheduled_time
 *   Timestamp indicating when the message will be sent. If 0 then scheduled
 *   time is disabled.
 * @param object $response
 *   Response object as returned by drupal_http_request().
 */
function hook_smsgatewayhub_after_send_sms($numbers, $message, $flash, $transactional, $scheduled_time, $response) {
  // Do something here.
}

Alter SMS

/**
 * Alter message or number here.
 *
 * This hook is invoked before hook_smsgatewayhub_before_send_sms().
 * You can perform alter operations in this hook.
 *
 * @param array $data
 *   Array with alterable data. Attributes of data are:
 *   - numbers: A string containing numbers, single or multiple separated with
 *     comma.
 *   - message: SMS message.
 *   - flash: Indicating whether this SMS to be sent as flash message.
 *   - transactional: Indicating whether this SMS to be sent as transactional
 *     SMS.
 *   - scheduled_time: Timestamp indicating when the message will be sent.
 */
function hook_smsgatewayhub_sms_alter(&$data) {
  // Do something here, like changing message text.
}

Help improve this page

Page status: Not set

You can: