Created
December 14, 2010 12:15
-
-
Save voodoojello/740334 to your computer and use it in GitHub Desktop.
Simple Boxcar Provider Broadcast Notification using Library for WWW in Perl (LWP)
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/perl -w | |
# | |
# boxcar-provider-broadcast.pl | |
# | |
# Simple Boxcar Provider Broadcast Notification using Library for WWW in Perl (LWP) | |
# Author: mark page [[email protected]] | |
# Modified: Tue Dec 14 06:13:31 CST 2010 | |
# | |
# | |
use strict; | |
use warnings; | |
use LWP::UserAgent; | |
my $api = { | |
'key' => 'xxxxxxxxxxxxxxxxxxxx', # 20 Char Provider API Key | |
'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', # 40 Char Provider API Secret | |
}; | |
my $broadcast = { | |
'from' => 'LWP Test', | |
'msg' => 'This is a broadcast notification from LWP Test at ' . localtime(time), | |
'url' => 'http://boxcar.io/devices/providers/' . $api->{key} . '/notifications/broadcast', | |
}; | |
my $browser = LWP::UserAgent->new; | |
my $response = $browser->post( | |
$broadcast->{url}, [ | |
'secret' => $api->{secret}, | |
'notification[from_screen_name]' => $broadcast->{from}, | |
'notification[message]' => $broadcast->{msg}, | |
'notification[from_remote_service_id]' => time, | |
'notification[redirect_payload]' => '', | |
'notification[source_url]' => 'http://your.url.here', | |
'notification[icon_url]' => 'http://your.url.to/image.here', | |
], | |
); | |
print $response->status_line . "\n"; | |
exit; | |
__END__ | |
notification[from_screen_name] | |
The user or application sending the notification. This is matched for | |
the redirect performed by Boxcar (if set by the user). This is a required | |
field. | |
notification[message] | |
The message to display to the user. This message should be at a maximum | |
somewhere around 140 characters in length. Longer messages will be truncated | |
depending on the client receiving it. This is a required field. | |
notification[from_remote_service_id] | |
An integer value that will uniquely identify the notification, and prevent | |
duplicate notifications about the same event from being created. This is an | |
optional field, but it is strongly recommended that you use it. | |
notification[redirect_payload] | |
Optional; The payload to be passed in as part of the redirection URL. Keep | |
this as short as possible. If your redirection URL contains "::user::" in | |
it, this will replace it in the URL. | |
notification[source_url] | |
Optional; This is a URL that may be used for future devices. It will replace | |
the redirect payload. | |
notification[icon_url] | |
Optional; This is the URL of the icon that will be shown to the user. | |
Standard size is 57x57. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment