Skip to content

Instantly share code, notes, and snippets.

@cloverstd
Created February 5, 2014 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cloverstd/8821241 to your computer and use it in GitHub Desktop.
Save cloverstd/8821241 to your computer and use it in GitHub Desktop.
boxcar
# -*- coding: utf-8 -*-
# http://boxcar.io
# send message to mobile
__author__ = "Cloverstd"
import urllib
import urllib2
import json
class Boxcar:
BASE_URL = "https://new.boxcar.io/api/"
SOUND = ["beep-crisp",
"beep-soft",
"bell-modern",
"bell-one-tone",
"bell-simple",
"bell-triple",
"bird-1",
"bird-2",
"boing",
"cash",
"clanging",
"detonator-charge",
"digital-alarm",
"done",
"echo",
"flourish",
"harp",
"light",
"magic-chime",
"magic-coin",
"notifier-1",
"notifier-2",
"notifier-3",
"orchestral-long",
"orchestral-short",
"score",
"success",
"up"]
def __init__(self, access_token):
self.access_token = access_token
def notice(self, title, message, sound):
result = self._send_notification(title, message, sound)
return json.loads(result)
def _send_notification(self, title, long_message, sound):
data = {"user_credentials": self.access_token,
"notification[title]": title,
"notification[long_message]": long_message,
"notification[sound]": sound
}
notifications_url = self.BASE_URL + "notifications"
response = urllib2.urlopen(notifications_url, urllib.urlencode(data))
return response.read()
if __name__ == '__main__':
boxcar = Boxcar("ACCESS_TOKEN")
print boxcar.notice("这是测试", "<a href='//ooxx.hui.lu'>测试一下</a>", Boxcar.SOUND[2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment