forked from jacobb/prowlpy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jacob Burch
authored and
Jacob Burch
committed
Jul 7, 2009
0 parents
commit becee0f
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Prowlpy V0.2 | ||
|
||
Written by Jacob Burch, 7/6/2009 | ||
|
||
Python module for posting to the iPhone Push Notification service Prowl: http://prowl.weks.net/ | ||
|
||
from prowlpy import Prowl | ||
p = Prowl(username='username',password='password') | ||
p.post('application','event','description') |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Prowlpy V0.2 | ||
Written by Jacob Burch, 7/6/2009 | ||
Python module for posting to the iPhone Push Notification service Prowl: http://prowl.weks.net/ | ||
from prowlpy import Prowl | ||
""" | ||
|
||
import httplib2 | ||
import urllib | ||
__author__ = 'jacobburch@gmail.com' | ||
__version__ = 0.2 | ||
|
||
class Prowl(object): | ||
def __init__(self,username,password): | ||
self.username = username | ||
self.password = password | ||
|
||
def post(self,application=None,event=None,description=None): | ||
h = httplib2.Http(".cache") | ||
h.add_credentials(self.username,self.password) | ||
headers = {'User-Agent': "ProwlScriptPy/%s" % str(VERSION)} | ||
|
||
data = {} | ||
application = urllib.quote(str(application)) | ||
event = urllib.quote(str(event)) | ||
desciption = urllib.quote(str(description)) | ||
|
||
resp,content = h.request("https://prowl.weks.net/api/add_notification.php?application=%s&event=%s&description=%s" / | ||
% (application, event, description)) | ||
|
||
if(resp['status']=='200'): | ||
print "Success!" | ||
elif(resp['status']=='401'): | ||
print "Auth Failed" | ||
else: | ||
print "Failed" |