Sending sms from your Drupal website

SMS with Drupal and Twilio

At the moment the Twilio service for sms from your Drupal site is still in Dev. I will be sending back some patches but for the moment these hacks will help you to run this service on your live site.

Inside the Twilio library InstanceResouces.php line 57

change to
 public function __get($key)
 {
 if ($subresource = $this->getSubresources($key)) {
 return $subresource;
 }
 if (!isset($this->$key)) {
 $params = $this->client->retrieveData($this->uri);
 $this->updateAttributes($params);
 } else {
 return $this->$key;
 }
}
Inside the Twilio Module (if you need country sign +) change this function to
 /**
 * Callback for sending messages.
 */
 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;
 // }
 // }
 sms_twilio_command('sendmsg', array('number' => $number, 'message' => $message), NULL, NULL);
 return true;
 }

We’ll come back to validation shortly.

2 thoughts on “SMS with Drupal and Twilio”

  1. hot on your twilio-trail!

    Just following the scent before diving into either voipdrupal or sms_twilio, and I came across this super-recent post. Where, specifically, might I best track your progress with Twilio + Drupal and contribute back?

    -Bronius (@bronicat and texas-bronius at d.o)

    1. Hi James – I’m not sure about UC3 as I’ve moved over to Drupal Commerce, which makes it much easier to add custom fields.

Leave a Reply

Your email address will not be published. Required fields are marked *

9 + 12 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>