Created
March 8, 2015 23:00
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
(ns tweet_linkz.core | |
(:use | |
[twitter.oauth] | |
[twitter.callbacks] | |
[twitter.callbacks.handlers] | |
[twitter.api.restful]) | |
(:import | |
(twitter.callbacks.protocols SyncSingleCallback))) | |
(def my-creds (make-oauth-creds "0yFM1B0UDmtufpLGli5ZKQ" | |
"CU6pYzpn5xWahR35IQtjr3zHoESWvTBB1ktVRjx1Qk0" | |
"56802003-bXoHirqGm6tQF8WMmx9m5wFYjWdaIUnL5k0rv328" | |
"RCvXBAdNBKWb3ZCuDSa3rHWdgfDHRp8qJavL6JeulM")) | |
(defn extract-link | |
[tweet] | |
(re-find #"http://\S+[^\W]" tweet)) | |
(def timeline-tweets | |
(map :text (statuses-home-timeline :oauth-creds my-creds | |
:params {:count 200} | |
:callbacks (SyncSingleCallback. response-return-body | |
response-throw-error | |
exception-rethrow)))) | |
(defn links-from-tweets | |
[tweets] | |
(remove nil? (map #(extract-link %) tweets))) | |
(defn -main | |
[] | |
(dorun | |
(map #(println %) (links-from-tweets timeline-tweets)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Muito legal! :)
Algumas coisinhas que da pra melhorar:
Also... da uma olhada nas macros
->
e->>
. Elas podem ajudar a colocar comandos em sequência em uma ordem mais lógica.