When am sending an sms to multiple users if one of the phone numbers has an issue Twilio throw an exception and the rest of my code is not executed. after digging into the code i discovered that there is need to catch the exceptions and pass them on watchdog so that the rest of the script can continue running here is the modification to the code
case '2010-04-01':
// Include the PHP TwilioRest library
require_once DRUPAL_ROOT . '/' . $config['sms_twilio_path'] . '/Services/Twilio.php';
$client = new Services_Twilio($AccountSid, $AuthToken);
switch ($command) {
case 'sendmsg':
try {
$response = $client->account->messages->create(array(
"From" => $twilio_number,
"To" => $data['number'],
"Body" => $data['message'],
));
}
catch (Services_Twilio_RestException $e) {
watchdog('sms_twilio', $e->getMessage());
}
break;
}
Comments
Comment #2
chrisrockwell commented@ecrown This is several months old but I'm trying to get things up-to-date here - can you provide a patch with your fix that can be tested?
Comment #3
chrisrockwell commentedComment #4
venutip commentedI just encountered a similar issue (Twilio throws a RestException if you try to message a blacklisted number) and have rolled a patch that catches the exception from Twilio. Note that I rolled this against 7.x-2.0.
Comment #5
timlie commentedRerolled patch against current DEV release.