Skip to content

Instantly share code, notes, and snippets.

@jage
Last active April 26, 2016 18:26
Show Gist options
  • Save jage/0a77b163fbe1f2461e7de6aa62289156 to your computer and use it in GitHub Desktop.
Save jage/0a77b163fbe1f2461e7de6aa62289156 to your computer and use it in GitHub Desktop.
  • lein new app clojure-twingly-search-api
  • edit clojure-twingly-search-api/project.cli and add dependencies:
  :dependencies [
                  [org.clojure/clojure "1.8.0"],
                  [com.twingly/twingly-search-api-java "1.0.0"]
                ]
  • lein install
  • lein run <keyword>
(ns clojure-twingly-search-api.core
(:gen-class))
(defn get-posts [keyword]
(->
(new com.twingly.search.client.UrlConnectionClient(System/getenv "TWINGLY_SEARCH_KEY"))
(.makeRequest (.build (com.twingly.search.QueryBuilder/create keyword)))
(.getPosts)))
; Lie, limited to 1000
(defn print-all-post-urls [keyword]
(doseq [post (get-posts keyword)]
(println (.getUrl post))))
(defn -main
[& args]
(print-all-post-urls (first args)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment