You are here

function sms_twilio_send in Twilio SMS Integration 7

Same name and namespace in other branches
  1. 6 sms_twilio.module \sms_twilio_send()
  2. 7.2 sms_twilio.module \sms_twilio_send()

Callback for sending messages.

1 string reference to 'sms_twilio_send'
sms_twilio_gateway_info in ./sms_twilio.module
Implements hook_gateway_info().

File

./sms_twilio.module, line 94
Adds support for sending SMS messages using the Twilio gateway.

Code

function sms_twilio_send($number, $message, $options) {
  $number = preg_replace("/[^0-9\\+]/", '', $number);
  $number = trim($number);
  $number = ltrim($number, '0');

  // Remove leading zeros
  if (isset($options['country'])) {
    $index = strpos($number, $options['country']);
    if ($index === FALSE || $index > 0) {
      $number = $options['country'] . $number;
    }
  }
  return sms_twilio_command('sendmsg', array(
    'number' => $number,
    'message' => $message,
  ), NULL, NULL);
}