Created
August 6, 2013 21:18
-
-
Save aamedina/6168739 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
(defn page! | |
[init-res req] | |
(reduce | |
(fn [coll n] | |
(if (not (= (mod (count coll) 200) 0)) (reduced coll) | |
(let [req (update-in | |
req [:query-params] | |
merge | |
{:since_id (:id_str (last coll))})] | |
(into coll (<!! (async-request req)))))) | |
init-res | |
(range 50))) | |
(defn timeline [user-id] | |
(go | |
(let [req (update-in (request (str rest-api "statuses/user_timeline.json")) | |
[:query-params] | |
merge {:user_id user-id :count 200}) | |
res (<! (async-request req))] | |
(page! res req)))) | |
(defn tweets [account-id] | |
(go | |
(let [users (map :user_id (<! (promotable-users account-id)))] | |
(<! (timeline (first users)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment