Java Reference
In-Depth Information
figure 10-23
➤
You might be trying to post or request too many tweets in rapid succession. Twitter applied
rate limiting to its services. Try again later.
➤
The parameters or endpoints might have changed (unlikely, as Twitter would assign a new
version number). Check Twitter's documentation.
Note
Note the shorthand notation used here to initialize an anonymous
HashMap:
new HashMap<String, String>() {{
put("count", "5");
}};
You can apply the same approach to initialize lists. Why the use of double braces
(
{{
and
}}
) here? The first set of braces creates a new anonymous inner class,
extending the
HashMap
object. The second set of braces declares an “instance
initializer” block that is run when the anonymous inner class is instantiated.
The only thing left do is actually parse the received JSON. To do so, you'll be using another Google
library called Google JSON, or GSON for short. You can find it at
https://code.google.com/p/
google-gson/
. I
nstallation is similar to what you've seen before—you download the latest version
(here,
google-gson-2.2.4-release.zip
is used), extract the ZIP file, copy
gson-2.2.4.jar
to a
Search WWH ::
Custom Search