add test call
This commit is contained in:
28
lib/DiscordAPI/src/DiscordAPI.cpp
Normal file
28
lib/DiscordAPI/src/DiscordAPI.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
#include "../include/DiscordAPI.h"
|
||||
|
||||
DiscordAPI::DiscordAPI(String hookUrl){
|
||||
this->hookUrl = hookUrl;
|
||||
|
||||
this->httpClient = new HTTPClient();
|
||||
this->wifiClient = new BearSSL::WiFiClientSecure;
|
||||
this->wifiClient->setInsecure();
|
||||
}
|
||||
|
||||
bool DiscordAPI::sendMessage(String message){
|
||||
bool sortie = true;
|
||||
|
||||
//TODO: faire test si le wifi est bien connecter
|
||||
|
||||
|
||||
this->httpClient->begin(*this->wifiClient, this->hookUrl);
|
||||
this->httpClient->addHeader("Content-Type", "application/json");
|
||||
|
||||
int resp = this->httpClient->POST("{\"content\":\""+ message +"\"}");
|
||||
if(resp != 204){
|
||||
sortie = false;
|
||||
Serial.print("sending message error code : ");
|
||||
Serial.println(resp);
|
||||
}
|
||||
this->httpClient->end();
|
||||
return sortie;
|
||||
}
|
Reference in New Issue
Block a user