按照 pushover API 的教程,我被卡住了。没有错误被抛出,但没有收到推送项目符号通知。这将成为智能门铃项目的一部分:
import http.client
import urllib.request, urllib.parse, urllib.error
import json
def pushOver(title,message,url):
app_key = " app key "
user_key = " user key "
# connect with the pushover API Server
conn = http.client.HTTPSConnection("api.pushover.net:443")
# send a POST request in urlencoded json
conn.request("POST", "/1/message.json",
urllib.parse.urlencode({
"token": app_key,
"user": user_key,
"title": title,
"message": message,
"url": url,
}), { "content-type": "application/x-www-form-urlencoded" })
# any errors messages or other resonces?
conn.getresponse()
# app-specifict varables
pushOver('Doorbell', 'started', '')
print ("doorbell server started")
print ("Finished")
对 python 来说相当新,已经将此代码转换为 python2 代码块,但现在卡住了,任何帮助都会得到很大的帮助。