-
-
Save uilian/72e908ef383bc6b26d34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab(group="org.twitter4j", module="twitter4j-core", version="4.0.2") | |
import twitter4j.* | |
import twitter4j.api.* | |
import twitter4j.conf.* | |
import org.pentaho.reporting.engine.classic.core.util.TypedTableModel; | |
colNames = ['Screen Name', 'Tweet Date', 'Text'] as String[] | |
colTypes = [String, Date, String] as Class[] | |
model = new TypedTableModel(colNames, colTypes); | |
ConfigurationBuilder cb = new ConfigurationBuilder(); | |
cb.setDebugEnabled(true) | |
.setOAuthConsumerKey(System.getenv('TWITTER_CONSUMER_TOKEN')) | |
.setOAuthConsumerSecret(System.getenv('TWITTER_CONSUMER_TOKEN_SECRET')) | |
.setOAuthAccessToken(System.getenv('TWITTER_ACCESS_TOKEN')) | |
.setOAuthAccessTokenSecret(System.getenv('TWITTER_ACCESS_TOKEN_SECRET')); | |
TwitterFactory tf = new TwitterFactory(cb.build()); | |
Twitter twitter = tf.getInstance(); | |
def query = new Query('#pentaho') | |
def result = twitter.search(query) | |
result?.tweets.each { tweet -> | |
model.addRow( [tweet.user.screenName, tweet.createdAt, tweet.text] as Object[] ) | |
} | |
return model; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment