hello there trying to finish up the prowl agent.
It is almost done, i only have one question, but first here is my code:
AGENT CODE:
// prowl Agent
const crowl_API_KEY = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”;
local prowl_title = “TEST”;
function send_prowl(body) {
local prowl_url = “https://api.prowlapp.com/publicapi/add?apikey=” + crowl_API_KEY + “&application=” + prowl_title + “&event=” + body; //setup url
server.log("Prowl URL: " + prowl_url);
server.log("Prowl data send: " + body); //pring body for testing
local req = http.post(prowl_url, {“Content-Type”:"application/x-www-form-urlencoded "}, body); //add headers
local res = req.sendsync(); //send request
if(res.statuscode != 200) {
server.log("error sending message: “+res.body);
}else device.send(“status”, (res.statuscode + " OK”)); //sends status
}
device.on("prowl", function(body) { //take from device
send_prowl(body); //send to function to call prowl
});
IMP CODE:
agent.send(“prowl”, “hello world” ); //send string to agent
So 2 questions please.
The example is supposed to send hello world. But i only get hello. Basically anything after first space is not displayed.
Is there any way this can be fixed?
Also , how could i send
agent.send(“prowl”, “hello world” ); //send string to agent
but also include the prowl_title as well instead of it being hardcoded on the agent?
Thanks in advance and i hope this code helps others too!
Thanks! That works… the only thing that doesnt work are the spaces in between though. So from your example this will work:
agent.send(“prowl”, { prowl_title = “prowl_title”, prowl_body = “hello_world”});
i know for sure i can send the message with spaces too. i have a php example that lets you do it. also if i use the address bar on the browser i can send: