Skip to content

Instantly share code, notes, and snippets.

@aamedina
Created August 6, 2013 21:18
Show Gist options
  • Save aamedina/6168739 to your computer and use it in GitHub Desktop.
Save aamedina/6168739 to your computer and use it in GitHub Desktop.
(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