
panda.ex.slack.Slacks Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of panda-core Show documentation
Show all versions of panda-core Show documentation
Panda Core is the core module of Panda Framework, it contains commonly used utility classes similar to apache-commons.
package panda.ex.slack;
import java.io.IOException;
import panda.bind.json.Jsons;
import panda.io.MimeTypes;
import panda.lang.Charsets;
import panda.net.http.HttpClient;
import panda.net.http.HttpMethod;
import panda.net.http.HttpRequest;
import panda.net.http.HttpResponse;
public class Slacks {
public static String sendWebHook(String url, Message msg) throws IOException {
HttpClient hc = new HttpClient();
HttpRequest hreq = hc.getRequest();
hreq.setUrl(url)
.setContentType(MimeTypes.APP_JSON)
.setMethod(HttpMethod.POST);
hreq.setEncoding(Charsets.UTF_8);
String body = Jsons.toJson(msg, true);
hreq.setBody(body);
HttpResponse hres = hc.send();
return hres.getContentText();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy