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'])) {
if ($options['country']=='00') // international prefix
$number='00'.$number;
else
{ // -1 or something else
$index = strpos($number, $options['country']);
if ($index === FALSE || $index > 0) {
$number = '00'.$options['country'] . $number;
}
}
}
return sms_twilio_command('sendmsg', array('number' => $number, 'message' => $message), NULL, NULL);
}
Comments
Comment #2
arne_hortell commentedComment #3
arne_hortell commentedComment #4
chrisrockwell commented@arne_hortell Thank you for filing an issue, sorry for the delay but I'm not getting notified when an issue is posted - I'll look into that.
As someone that's never used international numbers, can you give me more information on how what you'd expect to happen and what is actually happening?
Looking at how Clickatell implements this, I'm wondering if that implementation would solve the problem?
Comment #5
chrisrockwell commented@arne_hortell I think this is related to #1837754: Does not work with non north american phone numbers. Would you be willing to test that solution and see if it works for you? The only reason I haven't committed it yet is I'm just not up-to-date on International numbers.
Comment #6
arne_hortell commentedYes it is related as all numbers starting with +1 is either american or canadian and im swedish +46...
Comment #7
bildesbil commentedHello,
I have a little problem with the module sms framework on drupal I would like to know if you can help me!
I use the module with the twilio sms integration module. I have an error every time I try to send an SMS via my drupal site using the twilio gateway.
The framework removes the "+" from the international number and this generates an error in the twilio library. Saying that the number is valid.
I do not know if you can help me solve my problem
Best regards.
Comment #8
chrisrockwell commentedSorry for the delay in this, I'll take a look at this and the other linked issue before the end of this week.
Comment #9
chrisrockwell commentedI committed the patch from the issue to 1.x and 2.x