Reputation: 149
Using twttr and other Clojure twitter api libraries I have no issues with sending tweets or updates but I am unable to search or filter tweets for keywords.
I put the following command into the repl:
(ns twitter-search.core
(:require [twttr.api :as api ]
[twttr.auth :refer [env->UserCredentials]]))
I then input the credentials, as following:
(def app-consumer-key "my key from dev.twitter " )
And the same for app-consumer-secret access and secret token; all seems fine there as when I type in repl app-consumer-key it returns the key all fine.
Then for credentials I do :
(def creds (env->UserCredentials))
I get users show to work fine by writing a small function:
(defn show-user [handle]
(api/users-show creds :params {:screen_name handle}))
Then when I run (show-user "jack" ) in the repl I get all the json data one would expect so that is all fine and good.
The problem I am having is searching for tweets. When I put the following into the repl:
(api/search-tweets creds :params {:q "football"})
It does nothing, other than go from the current namespace
twitter-search.core=>
To
#_=>
If you could point out where I'm going wrong or send an example of how to search tweets containing certain words I would be most grateful.
I even did quite long tail searches and posted the same term from another twitter account to see if I could prompt the program to detect the tweet but nothing happened.
(ns twitter-search.core
(:require [twttr.api :as api ]
[twttr.auth :refer [env->UserCredentials]]))
(def app-consumer-key "my key from dev.twitter " )
(def creds (env->UserCredentials))
(defn show-user [handle]
(api/users-show creds :params {:screen_name handle}))
;; The problem I am having is searching for tweets.
;; When I put the following into the repl:
(api/search-tweets creds :params {:q "football"})
;; It does nothing, other than go from the current namespace
twitter-search.core=>
;; To
#_=>
I just want to be able to know how to use the twttr clojure library to filter out tweets based of certain keywords within their tweets. I know this probably seems a silly question, however, I am new to Clojure, I have not fouind a working example anywhere and have tried many times to get it to work.
Upvotes: 1
Views: 79
Reputation: 149
I feel very silly :-(
I was able to fix it, not sure what was causing the problem; I usually try fixing the problem several times and I usually answer it myself before posting here.
Anyway the following function returned what I was looking for:
(defn keyword-return [keyword]
(api/search-tweets creds :params {:q keyword}))
Upvotes: 2