Skip to content

Instantly share code, notes, and snippets.

@borkdude
Created October 14, 2011 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save borkdude/1287481 to your computer and use it in GitHub Desktop.
Save borkdude/1287481 to your computer and use it in GitHub Desktop.
twitter-api test script
(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