api - Cannot search for tweets using clojure twitter api twttr
问题描述
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.
解决方案
我觉得很傻:-(
我能够修复它,不确定是什么导致了问题;我通常会尝试多次解决问题,并且通常会在发布之前自己回答。
无论如何,以下函数返回了我正在寻找的内容:
(defn keyword-return [keyword]
(api/search-tweets creds :params {:q keyword}))
推荐阅读
- python - 如何在 Paramiko 中模拟我们自己的 ssh 二进制文件?
- java - Spring Rest 模板创建像邮递员一样工作的多部分表单/数据客户端抛出不可转换的异常
- javascript - 无法在 setTimeout 函数下获取组件变量
- plesk - 为什么 plesk 说网站的国家点击量来自商业 (.com)、网络 (.net)
- mysql - Python字节到geojson点
- javascript - 当 md-autocomplete 按下调用函数时
- node.js - 如何将 Javascript 连接到远程 IBM MQ?
- java - 如何将 ViewFlipper 与在线服务器/存储上的图像一起使用?
- php - 将 HTML 表格导出为 CSV 文件
- asp.net - 我只想显示显示名称而不是带有邮件 ID 的显示名称