[英]Neither Fabric for Android nor twitter4j find tweets containing a specific user's mention
I'm trying to retrieve tweets that mention an specific user either using fabric for android or twitter4j, but I'm not getting anything. 我正在尝试使用Android或twitter4j的结构检索提及特定用户的推文,但没有任何帮助。
-With Fabric for Android I'm doing it with "twitterApiClient.getSearchService().tweets" (logged in as a guest previously) -使用Android版Fabric,我使用“ twitterApiClient.getSearchService()。tweets”(以前以访客身份登录)进行操作
-With twitter4j, this is my code: -使用twitter4j,这是我的代码:
public List<Long> twList (String user){
List<Long> listTw = new ArrayList<>();
lastID = Long.MAX_VALUE;
int tamano = 0;
ArrayList<Status> tweets = new ArrayList<Status>();
String mention = "@"+user.trim();
query = new Query(user);
while (tweets.size() < numberOfTweets) {
tamano = tweets.size();
if (numberOfTweets - tweets.size() > 100) {
query.setCount(100);
} else {
query.setCount(numberOfTweets - tweets.size());
}
try {
QueryResult result = twitter.search(query);
tweets.addAll(result.getTweets());
Log.d("App", "Gathered " + tweets.size() + " tweets");
for (Status t : tweets) {
if (t.getId() < lastID) {
lastID = t.getId();
}
}
} catch (TwitterException te) {
Log.d("App", "Couldn't connect: " + te);
}
query.setMaxId(lastID - 1);
if (tamano == tweets.size()) break;
}
for (Status s: tweets){
if (s.getText().matches(mention)){
listTw.add(s.getId());
Log.d("App", s.getText());
}
}
tweets.clear();
return listTw;
}
When I look for the username on Twitter website, I get those tweets where it's mentioned. 当我在Twitter网站上查找用户名时,会得到提及的那些推文。
Any idea? 任何想法?
When was the last time a Tweet including the username you're searching for, posted? 上一次发布包含您要搜索的用户名的推文是什么时候? The Search API (which is used by both Fabric and Twitter4j) only covers around 7 days of data.
Search API(Fabric和Twitter4j均使用)仅涵盖大约7天的数据。 The website has the complete archive, but that is not available in the public Twitter API.
该网站具有完整的存档,但是在公共Twitter API中不可用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.