Created
December 18, 2015 15:07
-
-
Save fopina/5d9fd63f808be8f2afc5 to your computer and use it in GitHub Desktop.
Python function to push messages using https://qpush.me
This file contains hidden or 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
import urllib2 | |
import urllib | |
def qpushit(name, code, message): | |
data = urllib.urlencode({ | |
'name': name, | |
'code': code, | |
'sig': '', | |
'cache': False, | |
'msg[text]': message, | |
}) | |
try: | |
urllib2.urlopen('https://qpush.me/pusher/push_site/', data) | |
return True | |
except urllib2.HTTPError: | |
return False | |
if __name__ == '__main__': | |
import sys | |
if len(sys.argv) < 3: | |
print 'Usage: %s [device name] [device code] [message ...]' | |
sys.exit(2) | |
ret = qpushit(sys.argv[1], sys.argv[2], ' '.join(sys.argv[3:])) | |
if ret: | |
print 'Message sent' | |
sys.exit(0) | |
else: | |
print 'Message FAILED' | |
sys.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, does this program remain valid?