LoginSignup
3
3

More than 5 years have passed since last update.

Twitter4j で取得した情報をMapに落としこむ

Last updated at Posted at 2014-10-05

ポイント

zipmap を使用してMapを生成

ソースコード

xxx.clj
(ns sier-twitter-clj.core
  (:import [twitter4j TwitterFactory Query TwitterException])
  (:require [clojure.java.io :as io]))

(def twitter (. (TwitterFactory.) getInstance))

;; get twitter time line
;; return map
(defn get-timeline []
  (def x (.getHomeTimeline twitter))
  (map #(zipmap [:screenName :name :text] [(.. % getUser getScreenName)
                                           (.. % getUser getName)
                                           (.getText %)
                                           ]) x))

(defn -main []
  (def x (get-timeline))
  (println (class x))
  (println (first x))
  (println (second x)))

終わりに

もっと上手いやり方あるけど?
っていうのがあれば教えて下さい。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3