-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathReadMe.html
More file actions
205 lines (163 loc) · 8.94 KB
/
ReadMe.html
File metadata and controls
205 lines (163 loc) · 8.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<html>
<head>
<title>jPushbullet2 Read Me</title>
<style type="text/css">
<!--
body { font-family: Verdana; }
#apisupporttable { font-size: smaller; margin: 1em auto 1em auto; border-collapse: collapse; border-top: 2px solid black; border-bottom: 2px solid black; }
#apisupporttable th { cell-spacing: 1em; padding: 0.05em 1em 0.05em 1em; border-bottom: 1px solid black; }
#apisupporttable tr.supported:hover { background-color: #CEC; }
#apisupporttable tr.notsupported td{ color: #AAA; }
#apisupporttable tr.notsupported:hover{ background-color: #ECC; }
#apisupporttable td { cell-spacing: 1em; padding: 0.05em 1em 0.05em 1em; }
#apisupporttable th { text-align: center; }
#apisupporttable tr td:first-child + td { text-align: center; }
.depslist { font-size: smaller; margin-left: 4em; }
.depslist li { margin: 0.2em}
-->
</style>
</head>
<body>
<h1>jPushbullet2 Read Me</h1>
<p><a href="http://iharder.net/jpushbullet2">http://iharder.net/jpushbullet2</a></p>
<!-- BEGIN README -->
<p>
This is a <strong>Public Domain</strong> Java library for
interacting with the <a href="http://www.pushbullet.com">Pushbullet</a>
service. It supports both sending and receiving notifications.
Thanks to <a href="https://github.com/shakethat/jpushbullet">shakethat at github</a>
for the insights from his library, which was made for an earlier set of Pushbullet APIs.
Thanks to hakan42 at github for getting this library
<a href="https://github.com/rharder/jpushbullet2">converted and set up</a> for Maven.
</p>
<p>The <a href="https://docs.pushbullet.com/http/">Pushbullet HTTP API</a> identifies
seven capabilities, of which jPushbullet2 supports five:</p>
<table id="apisupporttable">
<thead><tr><th>Pushbullet API</th><th>Supported in <br />jPushbullet2</th><th>Future Plans</th></tr></thead>
<tbody>
<tr class="supported"><td><a href="https://docs.pushbullet.com/v2/pushes">/v2/pushes</a></td><td>Yes</td><td></td></tr>
<tr class="supported"><td><a href="https://docs.pushbullet.com/v2/devices">/v2/devices</a></td><td>Yes</td><td></td></tr>
<tr class="notsupported"><td><a href="https://docs.pushbullet.com/v2/contacts">/v2/contacts</a></td><td>No</td><td>Will explore this later</td></tr>
<tr class="supported"><td><a href="https://docs.pushbullet.com/v2/users/me">/v2/users/me</a></td><td>Yes</td><td></td></tr>
<tr class="supported"><td><a href="https://docs.pushbullet.com/v2/upload-request">/v2/upload-request</a></td><td>Yes</td><td></td></tr>
<tr class="notsupported"><td><a href="https://docs.pushbullet.com/v2/oauth2">/v2/oauth2</a></td><td>No</td><td>None</td></tr>
<tr class="supported"><td><a href="https://docs.pushbullet.com/stream">websocket</a></td><td>Yes</td><td></td></tr>
</tbody>
</table>
<p>View the <a href="api/index.html">jPushbullet2 javadoc API</a> online, if you like.</p>
<p>This jPushbullet2 library uses a few other libraries,
which you will need to add to your classpath/project:</p>
<ul class="depslist">
<li><a href="https://code.google.com/p/google-gson/">Google Gson</a> (for converting json text)</li>
<li><a href="http://hc.apache.org/">Apache HTTPComponents</a> (for communication with Pushbullet)</li>
<li><a href="https://java.net/projects/websocket-spec">javax.websocket</a> (<a href="https://tyrus.java.net/">Tyrus</a> a reference implementation)</li>
<li><a href="http://www.slf4j.org">SL4J</a> (for logging)
<ul>
<li><a href="http://logback.qos.ch">Logback</a> (or another logging back end)</li>
</ul>
</li>
</ul>
<p>So for instance my <tt>lib</tt> folder has the following files:</p>
<ul class="depslist">
<li>commons-codec-1.6.jar</li>
<li>commons-logging-1.2.jar</li>
<li>commons-lang-3.3.2.jar</li>
<li>fluent-hc-4.3.4.jar</li>
<li>gson-2.3.1.jar</li>
<li>httpclient-4.3.6.jar</li>
<li>httpclient-cache-4.3.4.jar</li>
<li>httpcore-4.3.2.jar</li>
<li>httpmime-4.3.6.jar</li>
<li>javax.json-1.0.4.jar</li>
<li>jcl-over-slf4j-1.7.7.jar</li>
<li>logback-classic-1.1.2.jar</li>
<li>logback-core-1.1.2.jar</li>
<li>slf4j-api-1.7.7.jar</li>
<li>tyrus-standalone-client-1.8.3.jar</li>
</ul>
<h2>Examples</h2>
<p>The quickest way to understand the library is to see some examples. These examples and more
are included in the source code. For security reasons, the examples are not included in the
binary distribution jar file.</p>
<p>To send a note:</p>
<code><pre class="prettyprint">
public class SendNote {
public static void main(String[] args) throws PushbulletException{
PushbulletClient client = new PushbulletClient( "ABCD1034...your.key.here...ABCD" );
String result = client.sendNote(null, "My First Push", "Great library. All my devices can see this!");
System.out.println( "Result: " + result );
} // end main
} // end Note
</pre></code>
<p>To retrieve, on another thread, all pushes ever sent with this Pushbullet account:</p>
<code><pre class="prettyprint">
public class GetPushesAsync {
public static void main(String[] args) throws PushbulletException, InterruptedException{
PushbulletClient client = new PushbulletClient( "ABCD1034...your.key.here...ABCD" );
Future fut = client.getPushesAsync(new Callback<List<Push>>() {
@Override
public void completed(List<Push> pushes, PushbulletException ex) {
System.out.println( "Number of pushes: " + pushes.size() );
System.out.println("Destination\ttype");
for( Push push : pushes ){
System.out.println(
push.getTarget_device_iden()+ "\t" +
push.getType() );
}
}
});
Thread.sleep(1000);
System.out.println("1 sec has passed. Done yet? " + fut.isDone() );
Thread.sleep(10000);
} // end main
} // end GetPushesAsync
</pre></code>
<p>To listen for new incoming pushes and other changes to your Pushbullet account:</p>
<code><pre class="prettyprint">
public class StartStopWebservice {
public static void main(String[] args) throws PushbulletException, InterruptedException{
if( args.length < 1 ){
System.out.println("Arguments: API_KEY ");
} else {
PushbulletClient client = new PushbulletClient( args[0] );
client.addPushbulletListener(new PushbulletListener(){
@Override
public void pushReceived(PushbulletEvent pushEvent) {
System.out.println("pushReceived PushEvent received: " + pushEvent);
}
@Override
public void devicesChanged(PushbulletEvent pushEvent) {
System.out.println("devicesChanged PushEvent received: " + pushEvent);
}
});
System.out.println("Getting previous pushes to find most recent...");
client.getPushes();
System.out.println("Starting websocket...try sending a push now.");
client.startWebsocket();
// Wait 30 seconds
for( int i = 30; i >= 0; i-- ){
System.out.print(" " + i + " ");
Thread.sleep(1000);
}
System.out.println("Stopping websocket");
client.stopWebsocket();
}
} // end main
} // end StartStopWebservice
</pre></code>
<h2>A Note About Public Domain</h2>
<p>I have released this software into the Public Domain. That means you can do whatever you want with it. Really. You don't have to match it up with any other open source license—just use it. You can rename the files, move the Java packages, whatever you want. If your lawyers say you have to have a license, contact me, and I'll make a special release to you under whatever reasonable license you desire: MIT, BSD, GPL, whatever.</p>
<h2>Changes</h2>
<ul>
<li>v0.3 -
Changed to SL4J logging.
Switched to Github.
Added Maven capability. Fixed "unchecked" warnings with generics.
Made binary distro compatible back to Java 1.6.</li>
<li>v0.2 - Adding paging capability. Changed Push sorting to be newest first
in keeping with Pushbullet.com practice. Cleaned up some dependencies.</li>
<li>v0.1 - Initial Release
</ul>
<!-- END README -->
</body>
</html>