Skip to content
Advertisement

Simple (Twitter + Streaming API + Java + OAuth) example

In my quest to create a simple Java program to extract tweets from Twitter’s streaming API, I have modified this (http://cotdp.com/dl/TwitterConsumer.java) code snippet to work with the OAuth method. The result is the below code, which when executed, throws a Connection Refused Exception.

I am aware of Twitter4J however I want to create a program that relies least on other APIs.

I have done my research and it looks like the oauth.signpost library is suitable for Twitter’s streaming API. I have also ensured my authentication details are correct. My Twitter Access level is ‘Read-only’.

I couldn’t find a simple Java example that shows how to use the streaming API without relying on e.g. Twitter4j.

JavaScript

Advertisement

Answer

I tried to simulate the code and found that the error was very simple. You should use https instead of http in the url 🙂

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement