Created
September 18, 2010 04:33
-
-
Save tototoshi/585361 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
(ns sample | |
(:import (twitter4j Query | |
QueryResult | |
Tweet | |
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