shlist

share and manage lists between multiple people
Log | Files | Refs

commit 513870209f43ae90a329bf539887dd5140e33ff0
parent da225944712ac9fadace7cf93dc09a2e20c0659d
Author: kyle <kyle@0x30.net>
Date:   Wed, 30 Dec 2015 02:18:34 -0700

pushd: add barebones android gcm client

- use https gcm protocol for now
- still needs an API key

Diffstat:
Apushd_android | 47+++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+), 0 deletions(-)

diff --git a/pushd_android b/pushd_android @@ -0,0 +1,47 @@ +#!/usr/bin/perl +use strict; +use warnings; + +use LWP::UserAgent; +use Getopt::Std; +use JSON::PP; + +my $api_key = "API key goes here"; +my $agent = "Shlist Pushd/0 "; + +my %args; +getopt("j:d:", \%args); + +unless ($args{j} && $args{d}) { + print "usage: ./$0 -j <json> -d <device>\n"; + exit 1; +} + +my %data = ( + to => "$args{d}", + data => { + message => "test test 1 2 3" + }, + notification => { + title => "the shlist is alive", + text => "move along" + } +); +my $json_text = encode_json(\%data); + +my $ua = LWP::UserAgent->new; +$ua->agent($agent); + +my $req = HTTP::Request->new(POST => 'https://android.googleapis.com/gcm/send'); +$req->authorization("key=$api_key"); +$req->content_type('application/json'); +$req->content($json_text); + +my $res = $ua->request($req); + +if ($res->is_success) { + print $res->content; +} +else { + print $res->status_line, "\n"; +}