如何解决Twitter4j 搜索
我正在尝试搜索 Twitter 推文。我使用 Twitter4j 库。 我的问题是我想搜索也包含我搜索的指定单词的主题标签。 例如: 如果我搜索 #hello,我希望我的结果是: #你好 #你好世界 #你好 等
这是我在搜索视图上的代码:
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener()
{
@Override
public boolean onQueryTextSubmit(String query1)
{
return false;
}
@Override
public boolean onQueryTextChange(String newText)
{
if(!newText.startsWith("#"))
{
newText = "#" + newText;
}
try {
Query query = new Query(newText);
query.setCount(100);
QueryResult result = twitter.search(query);
int c=1;
for(Status status: result.getTweets())
{
System.out.println("\nFor round:" + c+ "\nThe status is:"+ status.getText());
System.out.println("\n--------------");
System.out.println("\n-------Here are the hashtags for this post-------");
c++;
}
} catch (TwitterException e) {
e.printStackTrace();
}
但是当我在搜索栏上输入 hello 时,它只显示在我的控制台上(我知道我必须在屏幕上显示它们)带有 #hello 的推文。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。