PushOver versenden von Raspberry Pi: Unterschied zwischen den Versionen
Erscheinungsbild
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 1: | Zeile 1: | ||
http://pythonhosted.org/python-pushover/ | http://pythonhosted.org/python-pushover/ | ||
==Python3== | |||
<syntaxhighlight lang="python" line start="1" highlight="5" enclose="div"> | |||
import http.client, urllib | |||
# Application specific variables | |||
application_token = "akvfshmf6i2s6diskej9bd2jzufu7p" | |||
user_token = "uqsV4ZLmM8q7FjgtbjzyXrUZHheLdx" | |||
# Message specific variables | |||
title = "NightVision" | |||
message = "es ist etwas in die Kamerafalle gekommen" | |||
url = "" | |||
# To remove any of these fields you will need to remove them | |||
# from the conn.request() below | |||
# Start your connection with the Pushover API server | |||
conn = http.client.HTTPSConnection("api.pushover.net:443") | |||
# Send a POST request in urlencoded json | |||
conn.request("POST", "/1/messages.json", | |||
urllib.parse.urlencode({ | |||
"token": application_token, | |||
"user": user_token, | |||
"title": title, | |||
"message": message, | |||
"url": url, | |||
}), { "Content-type": "application/x-www-form-urlencoded" }) | |||
conn.getresponse() | |||
</syntaxhighlight> | |||
==Python2== | |||
<syntaxhighlight lang="python" line start="1" highlight="5" enclose="div"> | <syntaxhighlight lang="python" line start="1" highlight="5" enclose="div"> | ||
import httplib, urllib | import httplib, urllib | ||
Version vom 22. Oktober 2020, 10:55 Uhr
http://pythonhosted.org/python-pushover/
Python3
import http.client, urllib
# Application specific variables
application_token = "akvfshmf6i2s6diskej9bd2jzufu7p"
user_token = "uqsV4ZLmM8q7FjgtbjzyXrUZHheLdx"
# Message specific variables
title = "NightVision"
message = "es ist etwas in die Kamerafalle gekommen"
url = ""
# To remove any of these fields you will need to remove them
# from the conn.request() below
# Start your connection with the Pushover API server
conn = http.client.HTTPSConnection("api.pushover.net:443")
# Send a POST request in urlencoded json
conn.request("POST", "/1/messages.json",
urllib.parse.urlencode({
"token": application_token,
"user": user_token,
"title": title,
"message": message,
"url": url,
}), { "Content-type": "application/x-www-form-urlencoded" })
conn.getresponse()
Python2
import httplib, urllib
# Application specific variables
application_token = "YOUR APPLICATION TOKEN"
user_token = "YOUR USER TOKEN"
# Message specific variables
title = "A Simple Test"
message = "Saying hello from BeagleBone Black"
url = "http://michaelhleonard.com/blog"
# To remove any of these fields you will need to remove them
# from the conn.request() below
# Start your connection with the Pushover API server
conn = httplib.HTTPSConnection("api.pushover.net:443")
# Send a POST request in urlencoded json
conn.request("POST", "/1/messages.json",
urllib.urlencode({
"token": application_token,
"user": user_token,
"title": title,
"message": message,
"url": url,
}), { "Content-type": "application/x-www-form-urlencoded" })
# Listen for any error messages or other responses
conn.getresponse()