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.

Post your comment

Comments

  • Bronius Motekaitis 03/01/2013 4:35pm (4 years ago) Gravatar for Bronius Motekaitis

    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)

    • Kevin 26/07/2013 6:52pm (4 years ago) Gravatar for Kevin

      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.

RSS feed for comments on this page | RSS feed for all comments

Copywrite © 2017 Kevin Phillips All rights are reserved.

Proudly supporting opensource software