sps / pushover4j Goto Github PK
View Code? Open in Web Editor NEWpushover.net client
License: Apache License 2.0
pushover.net client
License: Apache License 2.0
Could you please provide examples on where to install/put this
Code example for the PushoverRestClient class with the dependencies to httpmime.
private static final ContentType plainUTF = ContentType.create("text/plain", MIME.UTF8_CHARSET);
public Status pushMessage(PushoverMessage msg) throws PushoverException {
final MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addTextBody("token", msg.getApiToken(), plainUTF);
builder.addTextBody("user", msg.getUserId(), plainUTF);
builder.addTextBody("message", msg.getMessage(), plainUTF);
addBodyIfNotNull(builder, "title", msg.getTitle());
addBodyIfNotNull(builder, "url", msg.getUrl());
addBodyIfNotNull(builder, "url_title", msg.getTitle());
addBodyIfNotNull(builder, "device", msg.getDevice());
addBodyIfNotNull(builder, "timestamp", "" + msg.getTimestamp());
addBodyIfNotNull(builder, "sound", msg.getSound());
addBodyIfNotNull(builder, "html", msg.isHtml() ? "1" : "0");
if (!MessagePriority.NORMAL.equals(msg.getPriority())) {
addBodyIfNotNull(builder, "priority", "" + msg.getPriority());
}
if (msg.getFile != null) {
builder.addBinaryBody("attachment", msg.getFile().getStream(), msg.getFile().getContentType(),
msg.getFile().getName());
}
HttpEntity multipart = builder.build();
HttpPost post = new HttpPost(PUSH_MESSAGE_URL);
post.setEntity(multipart);
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpResponse response = httpClient.execute(post);
return PushoverResponseFactory.createStatus(response);
} catch (Exception e) {
throw new PushoverException(e.getMessage(), e.getCause());
}
}
private void addBodyIfNotNull(MultipartEntityBuilder builder, String name, String value) {
builder.addTextBody(name, value, plainUTF);
}
The latest version of maven (1.0.0) doesn't contain any new pulls from 2013, please update maven for ease of access!
Hey there - I know it's something of a pain, but if it's not too much trouble, it would be super handy if this was published somewhere. I have it as an external dep for my projects, and I was thinking about pushing it to Central under my own groupId but figured you might rather have it under yours. :)
(It's a fantastic library, and thank you for working on it!)
Please include a method to verify a user key. https://pushover.net/api#verification
Thanks! :)
I may want to use your Java lib in a project of my own. However, I'm not sure what license this project is released under.
Can you add license information to your project?
I'm using Gradle in Android Studio to pull in pushover4j but get this runtime error when calling pushMessage:
java.lang.NoSuchMethodError: org.apache.http.client.entity.UrlEncodedFormEntity.
Any ideas?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.