0

按照 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 代码块,但现在卡住了,任何帮助都会得到很大的帮助。

4

1 回答 1

0

您正在获取响应,但没有对它做任何事情。打印出来,它可能会给你一些线索。

print(conn.getresponse())

于 2019-02-09T14:15:58.483 回答