SMS-Send-NANP-Twilio
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
CONTRIBUTING.md view on Meta::CPAN
# Contributing Guidelines
Fork repository on GitHub and submit a pull request.
Submitting a pull request indicates your acceptance of the license of the project.
Revision history for Perl extension SMS::Send::NANP::Twilio
0.06 2022-11-01
- Update license from Perl to MIT
- Updated scripts/perl-SMS-Send-NANP-Twilio-send_sms.pl to add command line options for AccountSid, AuthToken, MessagingServiceSid, and From
- Added GitHub repository
- Moved README to README.md
- Added LICENSE file
- Added CONTRIBUTING.md file
- Updated Makefile.PL to add meta merge github properties
0.05 2018-05-29
- Note: This version was never pushed to CPAN
- Updated lib/SMS/Send/NANP/Twilio.pm
- Moved from username to AccountSid
- Moved from password to AuthToken
- Added url override capabiltiy
0.04 2018-03-02
- Added DateTime as build time requirement - RT 124633 (ANDK@cpan.org)
- Updated Makefile.PL
- Updated perl-SMS-Send-NANP-Twilio.spec
0.03 2018-02-03
- API BREAK
- Changed sid property to API documented name MessagingServiceSid
- Changed from property to API documented case From
- Updated sms_send method
- Added support for MediaUrl property
- Added support for all optional properties in API documentation
0.02 2018-02-03
- Status return is different when using copilot
0.01 2018-02-03
- original version
MIT License
Copyright (c) 2022 Michael R. Davis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Changes
Makefile.PL
MANIFEST
README.md
LICENSE
CONTRIBUTING.md
t/001_load.t
t/002_send.t
t/003_send_MediaUrl.t
t/004_send_api.t
lib/SMS/Send/NANP/Twilio.pm
perl-SMS-Send-NANP-Twilio.spec
META.yml Module YAML meta-data (added by MakeMaker)
META.json Module JSON meta-data (added by MakeMaker)
{
"abstract" : "SMS::Send driver for Twilio",
"author" : [
"Michael Davis <mrdvt>"
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 7.52, CPAN::Meta::Converter version 2.150001",
"license" : [
"unknown"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : "2"
},
"name" : "SMS-Send-NANP-Twilio",
"no_index" : {
"directory" : [
"t",
"inc"
]
},
"prereqs" : {
"build" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"runtime" : {
"requires" : {
"DateTime" : "0",
"JSON::XS" : "0",
"SMS::Send::Driver::WebService" : "0.06",
"URI" : "0"
}
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/mrdvt92/perl-SMS-Send-NANP-Twilio/issues"
},
"homepage" : "https://github.com/mrdvt92/perl-SMS-Send-NANP-Twilio",
"repository" : {
"type" : "git",
"web" : "https://github.com/mrdvt92/perl-SMS-Send-NANP-Twilio.git"
}
},
"version" : "0.06"
}
---
abstract: 'SMS::Send driver for Twilio'
author:
- 'Michael Davis <mrdvt>'
build_requires:
ExtUtils::MakeMaker: '0'
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.52, CPAN::Meta::Converter version 2.150001'
license: unknown
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: SMS-Send-NANP-Twilio
no_index:
directory:
- t
- inc
requires:
DateTime: '0'
JSON::XS: '0'
SMS::Send::Driver::WebService: '0.06'
URI: '0'
resources:
bugtracker: https://github.com/mrdvt92/perl-SMS-Send-NANP-Twilio/issues
homepage: https://github.com/mrdvt92/perl-SMS-Send-NANP-Twilio
repository: https://github.com/mrdvt92/perl-SMS-Send-NANP-Twilio.git
version: '0.06'
Makefile.PL view on Meta::CPAN
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'SMS::Send::NANP::Twilio',
VERSION_FROM => 'lib/SMS/Send/NANP/Twilio.pm',
PREREQ_PM => {
'URI' => 0,
'JSON::XS' => 0,
'DateTime' => 0, #tests
'SMS::Send::Driver::WebService' => 0.06,
},
ABSTRACT_FROM => 'lib/SMS/Send/NANP/Twilio.pm',
AUTHOR => 'Michael Davis <mrdvt>',
'META_MERGE' => {
'resources' => {
'repository' => {
'web' => 'https://github.com/mrdvt92/perl-SMS-Send-NANP-Twilio.git',
'url' => 'git@github.com:mrdvt92/perl-SMS-Send-NANP-Twilio.git',
'type' => 'git'
},
'homepage' => 'https://github.com/mrdvt92/perl-SMS-Send-NANP-Twilio',
'bugtracker' => {
'web' => 'https://github.com/mrdvt92/perl-SMS-Send-NANP-Twilio/issues'
}
},
'meta-spec' => {'version' => 2},
},
);
# NAME
SMS::Send::NANP::Twilio - SMS::Send driver for Twilio
# SYNOPSIS
Configure /etc/SMS-Send.ini
[NANP::Twilio]
AccountSid=AccountSid
AuthToken=AuthToken
MessagingServiceSid=String
;From=+12025550123
;StatusCallback=URL
;ApplicationSid=String
;MaxPrice=USD
;ProvideFeedback=true|false
;ValidityPeriod=14400
use SMS::Send;
my $sms = SMS::Send->new('NANP::Twilio');
my $success = $sms->send_sms(text=> 'Hello World!', to =>'+17035550123');
use SMS::Send::NANP::Twilio;
my $sms = SMS::Send::NANP::Twilio->new;
my $success = $sms->send_sms(text=> 'Hello World!', to =>'+17035550123');
my $json = $sms->{__content};
my $href = $sms->{__data};
# DESCRIPTION
SMS::Send driver for Twilio
# METHODS
## send\_sms
Sends SMS Message via Twilio web service and returns 1 or 0. Method dies on critical error.
my $status = $sms->send_sms(to =>'+17035550123', text=> 'Hello World!');
my $status = $sms->send_sms(to =>'+17035550123', text=> 'Image Attached', MediaUrl=>'https://...');
- to
Passed as "To" in the posted form data. The destination phone number for SMS/MMS or a Channel user address for other 3rd party channels. Destination phone numbers should be formatted with a '+' and country code e.g., +16175550123 (E.164 format).
to => "+17035550123"
- text
Passed as "Body" in the posted form data. The text of the message you want to send, limited to 1600 characters.
text => "My Message Body"
- MediaUrl
The URL of the media you wish to send out with the message. gif, png, and jpeg content is currently supported and will be formatted correctly on the recipient's device. Other types are also accepted by the API. The media size limit is 5MB. If you...
MediaUrl => "https://...."
MediaUrl => [$url1, $url2, ...]
# PROPERTIES
Properties may be stored in Current Directory, /etc/SMS-Send.ini or C:\\Windows\\SMS-Send.ini. See [SMS::Send::Driver::WebService](https://metacpan.org/pod/SMS::Send::Driver::WebService)->cfg\_path
## url
Returns the url for the Twilio versioned service.
Default: https://api.twilio.com/2010-04-01
## AccountSid
The "AccountSID" is passed on the URL and sent as the username for basic authentication credentials
## AuthToken
The "AuthToken" sent as password for basic authentication credentials
## From
The "From" parameter passed in the posted form
A Twilio phone number (in E.164 format), alphanumeric sender ID or a Channel Endpoint address enabled for the type of message you wish to send. Phone numbers or short codes purchased from Twilio work here. You cannot (for example) spoof messages from...
## MessagingServiceSid
The "MessagingServiceSid" parameter passed in the posted form
The 34 character unique id of the Messaging Service you want to associate with this Message. Set this parameter to use the Messaging Service Settings and Copilot Features you have configured. When only this parameter is set, Twilio will use your enab...
## StatusCallback
The "StatusCallback" parameter passed in the posted form
A URL where Twilio will POST each time your message status changes to one of the following: queued, failed, sent, delivered, or undelivered. Twilio will POST the MessageSid along with the other standard request parameters as well as MessageStatus and...
## ApplicationSid
The "ApplicationSid" parameter passed in the posted form
Twilio will POST MessageSid as well as MessageStatus=sent or MessageStatus=failed to the URL in the MessageStatusCallback property of this Application. If the StatusCallback parameter above is also passed, the Application's MessageStatusCallback para...
## MaxPrice
The "MaxPrice" parameter passed in the posted form
The total maximum price up to the fourth decimal (0.0001) in US dollars acceptable for the message to be delivered. All messages regardless of the price point will be queued for delivery. A POST request will later be made to your Status Callback URL ...
## ProvideFeedback
The "ProvideFeedback" parameter passed in the posted form
Set this value to true if you are sending messages that have a trackable user action and you intend to confirm delivery of the message using the Message Feedback API. This parameter is set to false by default.
## ValidityPeriod
The "ValidityPeriod" parameter passed in the posted form
The number of seconds that the message can remain in a Twilio queue. After exceeding this time limit, the message will fail and a POST request will later be made to your Status Callback URL. Valid values are between 1 and 14400 seconds (the default)....
# SEE ALSO
[SMS::Send::Driver::WebService](https://metacpan.org/pod/SMS::Send::Driver::WebService), [SMS::Send](https://metacpan.org/pod/SMS::Send), [https://www.twilio.com/docs/api/messaging/send-messages](https://www.twilio.com/docs/api/messaging/send-message...
# AUTHOR
Michael R. Davis
# COPYRIGHT AND LICENSE
MIT License
Copyright (c) 2022 Michael R. Davis
lib/SMS/Send/NANP/Twilio.pm view on Meta::CPAN
package SMS::Send::NANP::Twilio;
use strict;
use warnings;
use URI;
use JSON::XS qw{decode_json};
use base qw{SMS::Send::Driver::WebService};
our $VERSION = '0.06';
=head1 NAME
SMS::Send::NANP::Twilio - SMS::Send driver for Twilio
=head1 SYNOPSIS
Configure /etc/SMS-Send.ini
[NANP::Twilio]
AccountSid=AccountSid
AuthToken=AuthToken
MessagingServiceSid=String
;From=+12025550123
;StatusCallback=URL
;ApplicationSid=String
;MaxPrice=USD
;ProvideFeedback=true|false
;ValidityPeriod=14400
use SMS::Send;
my $sms = SMS::Send->new('NANP::Twilio');
my $success = $sms->send_sms(text=> 'Hello World!', to =>'+17035550123');
use SMS::Send::NANP::Twilio;
my $sms = SMS::Send::NANP::Twilio->new;
my $success = $sms->send_sms(text=> 'Hello World!', to =>'+17035550123');
my $json = $sms->{__content};
my $href = $sms->{__data};
=head1 DESCRIPTION
SMS::Send driver for Twilio
=head1 METHODS
=head2 send_sms
Sends SMS Message via Twilio web service and returns 1 or 0. Method dies on critical error.
my $status = $sms->send_sms(to =>'+17035550123', text=> 'Hello World!');
my $status = $sms->send_sms(to =>'+17035550123', text=> 'Image Attached', MediaUrl=>'https://...');
=over
=item to
Passed as "To" in the posted form data. The destination phone number for SMS/MMS or a Channel user address for other 3rd party channels. Destination phone numbers should be formatted with a '+' and country code e.g., +16175550123 (E.164 format).
to => "+17035550123"
=item text
Passed as "Body" in the posted form data. The text of the message you want to send, limited to 1600 characters.
text => "My Message Body"
=item MediaUrl
The URL of the media you wish to send out with the message. gif, png, and jpeg content is currently supported and will be formatted correctly on the recipient's device. Other types are also accepted by the API. The media size limit is 5MB. If you wis...
MediaUrl => "https://...."
MediaUrl => [$url1, $url2, ...]
=back
=cut
sub send_sms {
my $self = shift;
my %argv = @_;
my $to = $argv{'to'} or die('Error: to propoerty required');
my $text = defined($argv{'text'}) ? $argv{'text'} : '';
my @form = (To => $to, Body => $text);
my $MediaUrl = $argv{'MediaUrl'} || [];
$MediaUrl = [$MediaUrl] unless ref($MediaUrl) eq 'ARRAY';
die('Error: MediaUrl - You may include up to 10 MediaUrls per message.') if @$MediaUrl > 10;
push @form, MediaUrl => $_ foreach @$MediaUrl;
my $status_response;
if ($self->From) {
push @form, From => $self->From;
$status_response = 'queued'; #When you only specify the From parameter, Twilio will validate the phone
#numbers synchronously and return either a queued status or an error.
}
if ($self->MessagingServiceSid) {
push @form, MessagingServiceSid => $self->MessagingServiceSid;
$status_response = 'accepted'; #When specifying the MessagingServiceSid parameter, Twilio will first
#return an accepted status.
}
die('Error: Property "From" or "MessagingServiceSid" must be configured.') unless $status_response;
push @form, StatusCallback => $self->StatusCallback if $self->StatusCallback;
push @form, ApplicationSid => $self->ApplicationSid if $self->ApplicationSid;
push @form, MaxPrice => $self->MaxPrice if $self->MaxPrice;
push @form, ProvideFeedback => $self->ProvideFeedback if $self->ProvideFeedback;
push @form, ValidityPeriod => $self->ValidityPeriod if $self->ValidityPeriod;
my $response = $self->uat->post_form($self->_url, \@form); #isa HASH from HTTP::Tiny
die(sprintf('HTTP Error: %s %s', $response->{'status'}, $response->{'reason'})) unless $response->{'success'};
$self->{'__content'} = $response->{'content'};
my $data = decode_json($response->{'content'});
$self->{'__data'} = $data;
return $data->{'status'} eq $status_response ? 1 : 0;
}
sub _url {
my $self = shift;
my $url = URI->new(join '/', $self->url, 'Accounts', $self->AccountSid, 'Messages.json');
$url->userinfo(join ':', $self->AccountSid, $self->AuthToken);
return $url;
}
=head1 PROPERTIES
Properties may be stored in Current Directory, /etc/SMS-Send.ini or C:\Windows\SMS-Send.ini. See L<SMS::Send::Driver::WebService>->cfg_path
=head2 url
Returns the url for the Twilio versioned service.
Default: https://api.twilio.com/2010-04-01
=cut
#see SMS::Send::Driver::WebService->url
sub _url_default {'https://api.twilio.com/2010-04-01'};
sub _host_default {'api.twilio.com'};
sub _protocol_default {'https'};
sub _port_default {'443'};
sub _script_name_default {'/2010-04-01'};
=head2 AccountSid
The "AccountSID" is passed on the URL and sent as the username for basic authentication credentials
=cut
sub AccountSid {
my $self = shift;
$self->{'AccountSid'} = shift if @_;
unless (defined $self->{'AccountSid'}) {
$self->{'AccountSid'} = $self->cfg_property('AccountSid', $self->_AccountSid_default)
|| $self->cfg_property('username', $self->_username_default); #pre 0.04
}
die('Error: AccountSid property required') unless defined $self->{'AccountSid'};
return $self->{'AccountSid'};
}
sub _AccountSid_default {undef};
=head2 AuthToken
The "AuthToken" sent as password for basic authentication credentials
=cut
sub AuthToken {
my $self = shift;
$self->{'AuthToken'} = shift if @_;
unless (defined $self->{'AuthToken'}) {
$self->{'AuthToken'} = $self->cfg_property('AuthToken', $self->_AuthToken_default)
|| $self->cfg_property('password', $self->_password_default); #pre 0.04
}
die('Error: AuthToken property required') unless defined $self->{'AuthToken'};
return $self->{'AuthToken'};
}
sub _AuthToken_default {undef};
=head2 From
The "From" parameter passed in the posted form
A Twilio phone number (in E.164 format), alphanumeric sender ID or a Channel Endpoint address enabled for the type of message you wish to send. Phone numbers or short codes purchased from Twilio work here. You cannot (for example) spoof messages from...
=cut
sub From {
my $self=shift;
$self->{'From'}=shift if @_;
$self->{'From'}=$self->cfg_property('From', $self->_From_default) unless defined $self->{'From'};
return $self->{'From'};
}
sub _From_default {undef};
=head2 MessagingServiceSid
The "MessagingServiceSid" parameter passed in the posted form
The 34 character unique id of the Messaging Service you want to associate with this Message. Set this parameter to use the Messaging Service Settings and Copilot Features you have configured. When only this parameter is set, Twilio will use your enab...
=cut
sub MessagingServiceSid {
my $self=shift;
$self->{'MessagingServiceSid'}=shift if @_;
$self->{'MessagingServiceSid'}=$self->cfg_property('MessagingServiceSid', $self->_MessagingServiceSid_default) unless defined $self->{'MessagingServiceSid'};
return $self->{'MessagingServiceSid'};
}
sub _MessagingServiceSid_default {undef};
=head2 StatusCallback
The "StatusCallback" parameter passed in the posted form
A URL where Twilio will POST each time your message status changes to one of the following: queued, failed, sent, delivered, or undelivered. Twilio will POST the MessageSid along with the other standard request parameters as well as MessageStatus and...
=cut
sub StatusCallback {
my $self=shift;
$self->{'StatusCallback'}=shift if @_;
$self->{'StatusCallback'}=$self->cfg_property('StatusCallback', $self->_StatusCallback_default) unless defined $self->{'StatusCallback'};
return $self->{'StatusCallback'};
}
sub _StatusCallback_default {undef};
=head2 ApplicationSid
The "ApplicationSid" parameter passed in the posted form
Twilio will POST MessageSid as well as MessageStatus=sent or MessageStatus=failed to the URL in the MessageStatusCallback property of this Application. If the StatusCallback parameter above is also passed, the Application's MessageStatusCallback para...
=cut
sub ApplicationSid {
my $self=shift;
$self->{'ApplicationSid'}=shift if @_;
$self->{'ApplicationSid'}=$self->cfg_property('ApplicationSid', $self->_ApplicationSid_default) unless defined $self->{'ApplicationSid'};
return $self->{'ApplicationSid'};
}
sub _ApplicationSid_default {undef};
=head2 MaxPrice
The "MaxPrice" parameter passed in the posted form
The total maximum price up to the fourth decimal (0.0001) in US dollars acceptable for the message to be delivered. All messages regardless of the price point will be queued for delivery. A POST request will later be made to your Status Callback URL ...
=cut
sub MaxPrice {
my $self=shift;
$self->{'MaxPrice'}=shift if @_;
$self->{'MaxPrice'}=$self->cfg_property('MaxPrice', $self->_MaxPrice_default) unless defined $self->{'MaxPrice'};
return $self->{'MaxPrice'};
}
sub _MaxPrice_default {undef};
=head2 ProvideFeedback
The "ProvideFeedback" parameter passed in the posted form
Set this value to true if you are sending messages that have a trackable user action and you intend to confirm delivery of the message using the Message Feedback API. This parameter is set to false by default.
=cut
sub ProvideFeedback {
my $self=shift;
$self->{'ProvideFeedback'}=shift if @_;
$self->{'ProvideFeedback'}=$self->cfg_property('ProvideFeedback', $self->_ProvideFeedback_default) unless defined $self->{'ProvideFeedback'};
return $self->{'ProvideFeedback'};
}
sub _ProvideFeedback_default {undef};
=head2 ValidityPeriod
The "ValidityPeriod" parameter passed in the posted form
The number of seconds that the message can remain in a Twilio queue. After exceeding this time limit, the message will fail and a POST request will later be made to your Status Callback URL. Valid values are between 1 and 14400 seconds (the default)....
=cut
sub ValidityPeriod {
my $self=shift;
$self->{'ValidityPeriod'}=shift if @_;
$self->{'ValidityPeriod'}=$self->cfg_property('ValidityPeriod', $self->_ValidityPeriod_default) unless defined $self->{'ValidityPeriod'};
return $self->{'ValidityPeriod'};
}
sub _ValidityPeriod_default {undef};
=head1 SEE ALSO
L<SMS::Send::Driver::WebService>, L<SMS::Send>, L<https://www.twilio.com/docs/api/messaging/send-messages>
=head1 AUTHOR
Michael R. Davis
=head1 COPYRIGHT AND LICENSE
MIT License
Copyright (c) 2022 Michael R. Davis
=cut
1;
perl-SMS-Send-NANP-Twilio.spec view on Meta::CPAN
Name: perl-SMS-Send-NANP-Twilio
Version: 0.06
Release: 1%{?dist}
Summary: SMS::Send driver for Twilio
License: Mit
Group: Development/Libraries
URL: http://search.cpan.org/dist/SMS-Send-NANP-Twilio/
Source0: http://www.cpan.org/modules/by-module/SMS/SMS-Send-NANP-Twilio-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
BuildRequires: perl(ExtUtils::MakeMaker)
BuildRequires: perl(DateTime)
BuildRequires: perl(JSON::XS)
BuildRequires: perl(SMS::Send)
BuildRequires: perl(SMS::Send::Driver::WebService) >= 0.06
BuildRequires: perl(URI)
Requires: perl(JSON::XS)
Requires: perl(SMS::Send::Driver::WebService) >= 0.06
Requires: perl(URI)
Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
%description
SMS::Send driver for Twilio
%prep
%setup -q -n SMS-Send-NANP-Twilio-%{version}
%build
%{__perl} Makefile.PL INSTALLDIRS=vendor
make %{?_smp_mflags}
%install
rm -rf $RPM_BUILD_ROOT
make pure_install PERL_INSTALL_ROOT=$RPM_BUILD_ROOT
find $RPM_BUILD_ROOT -type f -name .packlist -exec rm -f {} \;
find $RPM_BUILD_ROOT -depth -type d -exec rmdir {} 2>/dev/null \;
%{_fixperms} $RPM_BUILD_ROOT/*
%check
make test
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
%doc Changes README.md
%{perl_vendorlib}/*
%{_mandir}/man3/*
%changelog
t/001_load.t view on Meta::CPAN
use strict;
use warnings;
use Test::More tests => 17;
BEGIN { use_ok('SMS::Send::NANP::Twilio') };
my $ws = SMS::Send::NANP::Twilio->new(
AccountSid => 'myAccountSid',
AuthToken => 'myAuthToken',
MessagingServiceSid => '',
From => 'myFrom',
);
isa_ok($ws, 'SMS::Send::NANP::Twilio');
can_ok($ws, 'AccountSid');
can_ok($ws, 'AuthToken');
can_ok($ws, 'url');
can_ok($ws, 'From');
can_ok($ws, 'MessagingServiceSid');
can_ok($ws, 'StatusCallback');
can_ok($ws, 'ApplicationSid');
can_ok($ws, 'MaxPrice');
can_ok($ws, 'ProvideFeedback');
can_ok($ws, 'ValidityPeriod');
isa_ok($ws->uat, 'HTTP::Tiny');
is($ws->AccountSid, 'myAccountSid', 'AccountSid');
is($ws->AuthToken, 'myAuthToken', 'AuthToken');
is($ws->From, 'myFrom', 'From');
ok(!$ws->MessagingServiceSid, 'MessagingServiceSid');
t/002_send.t view on Meta::CPAN
# -*- perl -*-
use strict;
use warnings;
use DateTime;
use Data::Dumper qw{Dumper};
use Test::More tests => 4;
BEGIN { use_ok( 'SMS::Send::NANP::Twilio' ); }
my $to = $ENV{'SMS_TEST_PHONE_NUMBER'};
my $MessagingServiceSid = $ENV{'MessagingServiceSid'};
my $AccountSid = $ENV{'AccountSid'};
my $AuthToken = $ENV{'AuthToken'};
SKIP: {
skip 'ENV{SMS_TEST_PHONE_NUMBER} not configured', 3 unless $to;
my $service = SMS::Send::NANP::Twilio->new(
MessagingServiceSid => $MessagingServiceSid,
AccountSid => $AccountSid,
AuthToken => $AuthToken,
);
isa_ok ($service, 'SMS::Send::NANP::Twilio');
isa_ok ($service, 'SMS::Send::Driver');
my $text = sprintf("Message: Test 002, Time: %s", DateTime->now);
my $status=$service->send_sms(to => $to, text => $text);
diag(Dumper($service->{"__data"}));
ok($status, 'status');
}
t/003_send_MediaUrl.t view on Meta::CPAN
# -*- perl -*-
use strict;
use warnings;
use DateTime;
use Data::Dumper qw{Dumper};
use Test::More tests => 4;
BEGIN { use_ok( 'SMS::Send::NANP::Twilio' ); }
my $to = $ENV{'MMS_TEST_PHONE_NUMBER'};
my $MessagingServiceSid = $ENV{'MessagingServiceSid'};
my $AccountSid = $ENV{'AccountSid'};
my $AuthToken = $ENV{'AuthToken'};
SKIP: {
skip 'ENV{MMS_TEST_PHONE_NUMBER} not configured', 3 unless $to;
my $service = SMS::Send::NANP::Twilio->new(
MessagingServiceSid => $MessagingServiceSid,
AccountSid => $AccountSid,
AuthToken => $AuthToken,
);
isa_ok ($service, 'SMS::Send::NANP::Twilio');
isa_ok ($service, 'SMS::Send::Driver');
my $text = sprintf("Message: Test 003: Date: %s", DateTime->now);
my $url = 'http://maps.google.com/mapfiles/kml/shapes/post_office.png';
my $status = $service->send_sms(to => $to, text => $text, MediaUrl => $url);
diag(Dumper($service->{"__data"}));
ok($status, 'status');
}
t/004_send_api.t view on Meta::CPAN
# -*- perl -*-
use strict;
use warnings;
use DateTime;
use Data::Dumper qw{Dumper};
use Test::More tests => 4;
BEGIN { use_ok( 'SMS::Send' ); }
BEGIN { use_ok( 'SMS::Send::NANP::Twilio' ); }
{
package SMS::Send::NANP::Twilio;
no warnings;
sub _MessagingServiceSid_default {$ENV{'MessagingServiceSid'}};
sub _AccountSid_default {$ENV{'AccountSid'}};
sub _AuthToken_default {$ENV{'AuthToken'}};
}
my $to = $ENV{'SMS_TEST_PHONE_NUMBER_API'};
SKIP: {
skip 'ENV{SMS_TEST_PHONE_NUMBER_API} not configured', 2 unless $to;
my $service = SMS::Send->new('NANP::Twilio');
isa_ok ($service, 'SMS::Send');
my $text = sprintf("Message: Test 004, Time: %s", DateTime->now);
my $status = $service->send_sms(to => $to, text => $text);
ok($status, 'status');
}
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.427 second using v1.00-cache-2.02-grep-82fe00e-cpan-1925d2aa809 )