Created
December 24, 2012 17:41
-
-
Save jackrusher/4370149 to your computer and use it in GitHub Desktop.
Grab the last N tweets for user, where N is decided by Twitter's API limit.
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
(defn fetch-tweets | |
[user] | |
(loop [max-id nil accum []] | |
(let [fetch-str (str "https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&screen_name=" user "&count=1500" (when max-id (str "&max_id=" max-id))) | |
chunk (try (json/read-str (slurp fetch-str)) (catch Exception e))] | |
(if (or (nil? chunk) (< 200 (count chunk))) | |
(conj accum chunk) | |
(recur ((last chunk) "id") (conj accum chunk)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment