Created
September 11, 2010 06:05
-
-
Save tototoshi/574900 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import java.util.List | |
import twitter4j.Query | |
import twitter4j.QueryResult | |
import twitter4j.Tweet | |
import twitter4j.Twitter | |
import twitter4j.TwitterFactory | |
import scala.collection.JavaConversions._ | |
object SimpleTwitterSearchApp { | |
def search(word: String = "#rpscala") { | |
var query = new Query | |
query.setQuery(word) | |
println(query.getQuery) | |
val factory = new TwitterFactory | |
val twitter : Twitter = factory.getInstance | |
val results: QueryResult = twitter.search(query) | |
val tweets = results.getTweets | |
for (tweet <- tweets) { | |
print("@" + tweet.getFromUser + ": ") | |
println(tweet.getText) | |
} | |
} | |
def main(args: Array[String]){ | |
println(args(0)) | |
if (args.length != 0) { | |
search(args(0)) | |
}else{ | |
search() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment