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);
 } 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.


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)

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.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.