【问题标题】:Pushover script not getting required resultsPushover 脚本没有得到所需的结果
【发布时间】:2019-07-03 12:33:00
【问题描述】:

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

【问题讨论】:

  • 欢迎来到 StackOverflow!您能否更详细地描述您的问题:a)您的结果是什么? b) 您的期望结果是什么?
  • 结果是脚本执行但不发送消息没有推送消息没有显示错误我真的难倒它在树莓派上不确定我是否提到过#
  • 树莓派 3B Python 版本 3.5.3

标签: python raspberry-pi3 pushover


【解决方案1】:

您正在获取响应,但没有对其进行任何操作。把它打印出来,它可能会给你一些线索。

print(conn.getresponse())

【讨论】:

  • 我现在得到这个 Traceback(最近一次调用最后一次):文件“/home/pi/doorbell/test_pushbullet.py”,第 29 行,在 pushOver('Doorbell', 'started' , '') 文件“/home/pi/doorbell/test_pushbullet.py”,第 26 行,在 pushOver print(conn.getresponse()) 文件“/usr/lib/python3.5/http/client.py”,行1188,在 getresponse raise ResponseNotReady(self.__state) http.client.ResponseNotReady: Idle 任何帮助都会很棒
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-09
  • 2019-03-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多