need some help with my first python script. I suspect i have done it wrong but i cannot find the error....
Trying to upload current temp to a website (temperatur.nu)
- Code: Select all
import httplib, urllib
curTemp = indigo.devices[1204901047].displayStateValUi
id = "6488954"
city = "hofors"
params = urllib.urlencode({'s': city, 'id': id, 't': curTemp})
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
conn = httplib.HTTPConnection("www.temperatur.nu:80")
conn.request("POST", "/rapportera.php?", params, headers)
response = conn.getresponse()
print response.status, response.reason
data = response.read()
indigo.server.log(data)
conn.close()
# just some logging to see what i got
indigo.server.log(str(curTemp))
indigo.server.log(str(conn))
indigo.server.log(str(params))
here is the response i get. I suspect it is the connection string that is wrong some how. Translate first row (Fatal, failure! Could not match city and id)
- Code: Select all
Script Fatal, failure! Kan inte inte matcha stad och id!
Script 10.5
Script <httplib.HTTPConnection instance at 0x5e3dc88>
Script s=hofors&id=6488954&t=10.5