Quantcast
Channel: Oracle Bloggers
Viewing all articles
Browse latest Browse all 19780

Nashorn in the Twitterverse

$
0
0

I have been following how often Nashorn has been showing up on the net.  Nashorn got a burst of tweets when we announced Project Nashorn and I was curious how Nashorn was trending per day, maybe graph the result.  Counting tweets manually seemed mindless, so why not write a program to do the same.

This is where Nashorn + Java came shining through.  There is a very nice Java library out there called Twitter4J https://github.com/yusuke/twitter4j that handles all things Twitter.  After running bin/getAccessToken.sh to get a twitter4j.properties file with personal authorization, all I had to do to run my simple exploratory app was;

nashorn -cp $TWITTER4J/twitter4j-core-3.0.1.jar GetHomeTimeline.js

The content of GetHomeTimeline.js is as follows;

var twitter4j      = Packages.twitter4j;var TwitterFactory = twitter4j.TwitterFactory;var Query          = twitter4j.Query;var twitter = new TwitterFactory().instance;var query   = new Query("nashorn OR nashornjs");query.count = 100;do {    var result = twitter.search(query);    var tweets = result.tweets;    for each (tweet in tweets) {        print("@" + tweet.user.screenName + "\t" + tweet.text);    }} while (query = result.nextQuery());

How easy was that?  Now to hook it up to the JavaFX graphing library... 


Viewing all articles
Browse latest Browse all 19780

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>