Created
October 14, 2011 15:54
-
-
Save borkdude/1287481 to your computer and use it in GitHub Desktop.
twitter-api test script
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 twitter-api-test.followers-minus-friends | |
(:use | |
[twitter.api.restful :only [show-followers show-friends lookup-users]] | |
[clojure.set :only [difference]]) | |
(:require [clojure.string :as string])) | |
(defn vector-to-comma-separated [vector] | |
(string/join "," vector)) | |
(defn userinfos [idset] | |
(let [groups-of-100-ids (partition-all 100 idset)] | |
;; the api only allows 100 ids at a time | |
(mapcat #(:body (lookup-users :params {:user_id (vector-to-comma-separated %)})) | |
groups-of-100-ids))) | |
(defn idset [twitter-fn screenname] | |
(set (:body | |
(twitter-fn :params {:screen-name screenname})))) | |
(defn followers-minus-friends [screenname] | |
(let [difference-ids (difference (idset show-followers screenname) | |
(idset show-friends screenname)) | |
userinfos (userinfos difference-ids)] | |
(map :screen_name userinfos))) | |
;(followers-minus-friends "Borkdude") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment