voodoojello
12/13/2010 - 3:01 AM

Simple Boxcar User Invitation using Library for WWW in Perl (LWP)

Simple Boxcar User Invitation using Library for WWW in Perl (LWP)

#!/usr/bin/perl -w
#
# Simple Boxcar User Invitation using Library for WWW in Perl (LWP)
# Author: mark page [m.e.page@voodoojello.net]
# Modified: Sun Dec 12 20:59:42 CST 2010
#
# expects Boxcar user sign-up address, *not* push.boxcar.io address as $ARGV[0]
#
use strict;
use warnings;
use Digest::MD5 "md5_hex";
use LWP::UserAgent;

unless (@ARGV) { die "no email adddress provided!"; }

my $email_md5 = md5_hex($ARGV[0]);
my $api_key   = 'XXXXXXXXXXXXXXXXXXXX';	# 20 char provider API key

my $notification = {
	'url'  => 'http://boxcar.io/devices/providers/' . $api_key . '/notifications/subscribe',
	};

my $browser  = LWP::UserAgent->new;
my $response = $browser->post(
	$notification->{url}, [
		'email'  => $email_md5,
		],
	);

for my $key (keys %{$response}) { print $key . ': ' . $response->{$key} . "\n"; }

exit;

__END__