mbeijen / sms-send-twilio Goto Github PK
View Code? Open in Web Editor NEWperl5 SMS::Send driver using Twilio API
Home Page: https://metacpan.org/pod/SMS::Send::Twilio
License: Other
perl5 SMS::Send driver using Twilio API
Home Page: https://metacpan.org/pod/SMS::Send::Twilio
License: Other
It would be nice if you built your object on top of SMS::Send::Driver::WebService so you could save account settings in standard INI file.
/etc/SMS-Send.ini
[Twilio]
username=ACb657bdcb16f06893fd127e099c070eca
password=b857f7afe254fa86c689648447e04cff
from=+15005550006
Then the constructor is simply.
use SMS::Send;
my $cheapest_sms_driver='Twilio';
my $sender = SMS::Send->new($cheapest_sms_driver);
See Also: SMS::Send::NANP::TextPower, SMS::Send::NANP::Raco_TMO
We are getting errors like this:
Can't escape \x{014D}, try uri_escape_utf8() instead at /usr/local/share/perl/5.28.1/WWW/Twilio/API.pm line 116.
It appears that WWW::Twilio::API has a param "utf8" for new() that would cause the module to use uri_escape_utf8, but there doesn't appear to be a way to enable it in SMS::Send::Twilio.
If it could be added as a parameter to new() that would be great!
You may want to consider this: https://support.twilio.com/hc/en-us/articles/223181028-Switching-from-SMS-Messages-resource-URI-to-Messages-resource-URI-
It seems to reduce to simply update only one line of code.
For such a minimal change I'm neglecting doing a pull request right now...
In Twilio's console the change is evident in that requests using [the deprecated] SMS/Messages
have no "Delivery Steps", while the ones using /Messages
have. It may be not a critical feature, but it is certainly a useful one.
In your sample code you show the following
_auth_token => 'b857f7afe254fa86c689648447e04cff',
it should be
_authtoken => 'b857f7afe254fa86c689648447e04cff',
Otherwise you get the following error: SMS::Send::Twilio->new requires _authtoken parameter
I was confused about commit 00458bb and die-ing if send_sms fails.
The POD docs say this about new
:
Returns a new SMS::Send object, or dies on error.
But regarding send_sms
they say:
The send_sms returns true if the message was sent, or the driver is fire-and-forget and unable to determine success, or false if the message was not sent.
Also, the code for SMS::Send::send_sms
has:
# Merge params and hand off
my $rv = $self->_OBJECT_->send_sms(
text => $text,
to => $to,
$self->_PRIVATE(@_),
);
# Verify we get some sort of result
unless ( defined $rv ) {
Carp::croak("Driver did not return a result");
}
return $rv;
So the code that is calling the Twilio driver only croaks if an undef is returned. It's expecting a true/false from the driver which is returned to the caller.
I can understand die/croak-ing if something goes wrong in new
but die/croak-ing in send_sms
doesn't seem to match what SMS::Send expects. In the situation where the driver is working and configured but there is a problem with sending to Twilio, I would expect a true/false result.
For various reasons, the request may fail. In my case it was a missing dependency.
In such case there is no indication what happened.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.