java - twitter hbc 调用streaming api 获取不到响应数据

 mobiledu2502883317 发布于 2022-10-29 19:03

1.按照github上的示例代码写的
https://github.com/twitter/hb...
2.代码入下

    public class FilterStreamExample {
    public static void main(String[] args) throws InterruptedException {
        run("consumerKey", "consumerSecret", "token", "secret");
    }

    public static void run(String consumerKey, String consumerSecret, String token, String secret) throws InterruptedException {
        BlockingQueue queue = new LinkedBlockingQueue(10000);
        StatusesFilterEndpoint endpoint = new StatusesFilterEndpoint();
        endpoint.trackTerms(Lists.newArrayList("twitterapi", "#yolo"));
        Authentication auth = new OAuth1(consumerKey, consumerSecret, token, secret);
        Client client = new ClientBuilder()
                .hosts(Constants.STREAM_HOST)
                .endpoint(endpoint)
                .authentication(auth)
                .processor(new StringDelimitedProcessor(queue))
                .build();
        client.connect();
        for (int msgRead = 0; msgRead < 1000; msgRead++) {
            String msg = queue.take();
            System.out.println(msg);
        }
        client.stop();
    }
}
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有