Pushover script not getting required results

256 Views Asked by At

Following a tutorial for pushover API and I'm stuck. No errors are being thrown up but don't get push bullet notification. This is going to be part of a smart door bell project:

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")

Quite new to python already converted this code form a python2 block of code but now stuck any help would be greatly received.

1

There are 1 best solutions below

1
jcs On

You're fetching the response but not doing anything with it. Print it out and it will probably give you some clues.

print(conn.getresponse())