You are here

function sms_twilio_send in Twilio SMS Integration 6

Same name and namespace in other branches
  1. 7.2 sms_twilio.module \sms_twilio_send()
  2. 7 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
Implementation of hook_gateway_info().

File

./sms_twilio.module, line 86
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
  $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, $account);
}