[Bps-public-commit] rt-extension-notifysms branch, master, updated. db448de7419867e537f493de3def96904f5063a9
Craig Kaiser
craig at bestpractical.com
Wed Jul 18 13:18:19 EDT 2018
The branch, master has been updated
via db448de7419867e537f493de3def96904f5063a9 (commit)
from 9abff28853ad445ec2aa6e9d39ba0cc400a82fa2 (commit)
Summary of changes:
lib/RT/Action/NotifyTwilio.pm | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
- Log -----------------------------------------------------------------
commit db448de7419867e537f493de3def96904f5063a9
Author: Craig Kaiser <craig at bestpractical.com>
Date: Wed Jul 18 13:17:59 2018 -0400
Allow Twilio api url to be set in config options
diff --git a/lib/RT/Action/NotifyTwilio.pm b/lib/RT/Action/NotifyTwilio.pm
index 76dd015..0875f01 100644
--- a/lib/RT/Action/NotifyTwilio.pm
+++ b/lib/RT/Action/NotifyTwilio.pm
@@ -14,10 +14,14 @@ config values from RT_SiteConfig.pm:
Set($TwilioAccounId, 'Secret');
Set($TwilioAuthToken, 'Secret');
+ Set($APIURL, 'https://api.twilio.com/2010-04-01/Accounts');
Set($APIDomain, 'api.twilio.com:443');
Set($APIRealm, 'Twilio API');
- Set($MessageSender, 0123456789);
+ Set($MessageSender, '0123456789');
+To obtain the Twilio AuthToken and AccountId create a new project of type
+programmable sms. Once done setting up the project you will have access to
+the projects AccountId and AuthToken.
=cut
sub SendMessage {
@@ -47,11 +51,8 @@ sub SendMessage {
my %Twilio = (
api_domain => RT::Config->Get('APIDomain'),
api_realm => RT::Config->Get('APIRealm'),
- from => RT::Config->Get('MessageSender'),
-
- api_url => 'https://api.twilio.com/2010-04-01/Accounts/'
- . $Credentials{account_id}
- . '/Messages.json'
+ api_url => RT::Config->Get('APIURL'),
+ from => RT::Config->Get('MessageSender')
);
my $ua = LWP::UserAgent->new;
@@ -66,7 +67,12 @@ sub SendMessage {
To => $to,
Body => $args{Msg},
);
- my $response = $ua->post( $Twilio{api_url}, \%text_message );
+ my $response = $ua->post(
+ $Twilio{api_url}
+ . $Credentials{account_id}
+ . '/Messages.json',
+ \%text_message
+ );
if ( $response->is_error ) {
my $result = decode_json( $response->content );
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list