【问题标题】:How to get a Twitter4j keyword that's being returned by twitter?如何获取 twitter 返回的 Twitter4j 关键字?
【发布时间】:2015-08-21 16:10:55
【问题描述】:

我正在构建一个使用 Apache Storm 和库 Twitter4j 来处理实时 Twitter 的系统。但我有一个问题:有办法知道哪个关键字过滤器给了我这条推文吗?

例子:

//Topology builder parameter
String keywords = {"Keyword 1", "Keyword 2"};

//Call of Twitter strem API return
  @Override
  public void execute(Tuple tuple, BasicOutputCollector collector) {
      Status status = (Status) tuple.getValueByField("tweet");
      System.out.println(status);
  }

//Result of Sysout
StatusJSONImpl{createdAt=Thu Aug 20 16:55:52 BRT 2015, id=645265788760587264, text='RT @user: This is a Keyword 1 tweet' ... }

StatusJSONImpl{createdAt=Thu Aug 20 16:55:56 BRT 2015, id=645265788760587265, text='RT @user: This is a Keyword 2 tweet' ... }

如果不进行字符串比较,我如何知道使用了哪个关键字?我没有找到具有关键字的对象的任何属性,只有推文数据。

【问题讨论】:

    标签: twitter twitter4j twitter-streaming-api apache-storm


    【解决方案1】:

    Twitter 流 API 仅返回标准推文 payloads ,它不会添加任何关于您的查询的额外元数据。完成您要求的唯一方法是根据您的关键字列表处理消息客户端。

    【讨论】:

    • 啊好吧!非常感谢!
    猜你喜欢
    • 1970-01-01
    • 2012-06-15
    • 2014-03-01
    • 2014-01-07
    • 1970-01-01
    • 2014-03-25
    • 2013-07-23
    • 2012-08-03
    • 1970-01-01
    相关资源
    最近更新 更多