Created
August 22, 2016 07:37
-
-
Save artifactsauce/7592d290c484b896dd1b4f7b5173e071 to your computer and use it in GitHub Desktop.
Simple test script to post to slack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use utf8; | |
use JSON; | |
use Data::Dumper; | |
use LWP::UserAgent; | |
my $url = $ENV{SLACK_WEBHOOK_URL}; | |
my $channel = '#sandbox'; | |
my $username = 'Test Agent'; | |
my $icon = ':jack_o_lantern:'; | |
my $message = $ARGV[0]; | |
my $post_data = { | |
payload => encode_json +{ | |
channel => $channel, | |
username => $username, | |
icon_emoji => $icon, | |
text => $message, | |
}, | |
}; | |
my $headers = {}; | |
my $ua = LWP::UserAgent->new; | |
my $response = $ua->post($url, $post_data, %$headers); | |
unless ($response->is_success) { | |
warn $response->status_line; | |
} | |
exit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
requires 'JSON'; | |
requires 'LWP::UserAgent'; | |
requires 'LWP::Protocol::https'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment