Java Reference
In-Depth Information
After executing this code (don't forget to fill in your username and password), you should receive
something like the following output:
Trying to log into Twitter...
Cookies are now:
{twid="u=9807092", guest_id=v1%3A139809069245291074, remember_checked_on=1,
auth_token=0a5fe41724884eaab2e8b121e6ed74d6f74a2754,
_twitter_sess=BAh7CiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo
%250ASGFzaHsABjoKQHVzZWR7ADoHaWQiJTRiM2IyN2VjMDZkZGMxZTVjNzc2MGI1%250AOTBh
NzAwN2U1Og9jcmVhdGVkX2F0bCsIZfeyhEUBOgxjc3JmX2lkIiUzMGQ2%250ANzNkMjQxNjRiN
TMzNDgzNzBjYTJiMDZjZWNhZjoJdXNlcmkD9KSV--4244a4f3d399fab8a4eda1a3ad69e3f29
6a23c84, lang=en,
h=%7B%22tweet_id%22%3A%22456581708179972100%22%2C%22advertiser_id%22%3A%22
121336088%22%2C%22newer_tweet_id%22%3A%22458251425135734784%22%2C%22
older_tweet_id%22%3A%22458251414578270208%22%2C%22promoted_content%22%3A%7B%22
impression_id%22%3A%2242597fa3f64f6b16%22%2C%22disclosure_type%22%3A%22
promoted%22%2C%22disclosure_text%22%3A%22%22%7D%2C%22experiment_values%22%3A%7B%22
display.display_style%22%3A%22show_social_context%22%7D%7D}
Your username is: ** YOUR USERNAME **
Your stats:
- Tweets: 556
- Following: 377
- Followers: 143
@WileyTech stats:
- Tweets: 1 943
- Following: 897
- Followers: 3 832
creating your oWn WeB services With Java
Now that you've seen how to access web services, you might be wondering how you can offer your
own information over the web using Java. Java has excellent support for setting up web servers, ser-
vices, and applications, but a full discussion of those is out of scope for a beginner's book.
Instead, this topic will be using a simple framework—aptly named “Simple”—which can be down-
loaded from http://www.simpleframework.org/ . Like always, create a new project in Eclipse
( HTTPServer , for instance) and unzip the JAR file ( simple-6.0.1.jar ) to a folder in Eclipse (e.g.,
simple ). Finally, add the JAR file to the build path.
setting up an http server
Create a class called HTTPServer with the following source code:
import java.awt.Desktop;
import java.io.PrintStream;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.net.URI;
import org.simpleframework.http.Request;
 
Search WWH ::




Custom Search