Skip to content

Instantly share code, notes, and snippets.

@tototoshi
Created September 18, 2010 04:33
Show Gist options
  • Save tototoshi/585361 to your computer and use it in GitHub Desktop.
Save tototoshi/585361 to your computer and use it in GitHub Desktop.
(ns sample
(:import (twitter4j Query
QueryResult
Tweet
Twitter
TwitterFactory)))
(def twitter-api (.. (TwitterFactory.) getInstance))
(defn make-query [word]
(let [q (Query.)]
(do (. q setQuery word)
q)))
(defn get-search-result [word]
(let [q (make-query word)
res (. twitter-api search q)]
(.getTweets res)))
(defn search-tweets [& word]
(for [tweet (get-search-result (or (first word) "#clojure"))]
(let [user (.getFromUser tweet)
text (.getText tweet)]
(str "@" user ": " text))))
(defn search [& word]
(println
(reduce
(fn [x y] (str x "\n" y)) (search-tweets (first word)))))
(search)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment