-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathESPushover.cpp
22 lines (19 loc) · 1.03 KB
/
ESPushover.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "ESPushover.h"
ESPushover::ESPushover(String token, String user) {
_token = token;
_user = user;
}
int ESPushover::send(ESPushoverMessage espushovermessage) {
WiFiClientSecure client;
HTTPClient http;
client.setInsecure();
if (!client.connect("api.pushover.net", 443)) {
return -1;
}
String postmessage = String("token=")+_token+"&user="+_user+"&title="+espushovermessage.getTitle()+"&message="+espushovermessage.getMessage()+"&device="+espushovermessage.getDevice()+"&url="+espushovermessage.getUrl()+"&url_title="+espushovermessage.getUrlTitle()+"&priority="+espushovermessage.getPriority()+"&retry="+espushovermessage.getRetry()+"&expire="+espushovermessage.getExpire()+"&sound="+espushovermessage.getSound();
if (espushovermessage.getTimestamp() != 0) postmessage += String("×tamp=")+espushovermessage.getTimestamp();
if (espushovermessage.getIsHTML() == true) postmessage += String("&html=1");
http.begin(client,"https://api.pushover.net/1/messages.json");
int httpCode = http.POST(postmessage);
return httpCode;
}