Twitter APIs and authentication



I have two questions. First of all, i’m building an app which should keep on searching tweets based on a specific keyword , filter, do some processing and persists in database. The app will be displaying some statistical analysis details based on the data retreived and processed. The webpage will be refreshing in timely manner to show new data received and processed. To address this kind of scenario, which API should i consider as the best option?

Also, i’m using twitter4j as client. The following code throws:

401:Authentication credentials ( were missing or incorrect. Ensure that you have set valid consumer key/secret, acc
ess token/secret, and the system clock is in sync.
The screen name / password combination seems to be invalid.

What can be the problem? I have verified the keys and they seems to be fine.

try {
	Twitter twitter = TwitterFactory.getSingleton();
	twitter.setOAuthConsumer("xxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxx");

	RequestToken twitterRequestToken = twitter.getOAuthRequestToken();
	String token = twitterRequestToken.getToken();
	String tokenSecret = twitterRequestToken.getTokenSecret();

	AccessToken accessToken =  twitter.getOAuthAccessToken(token, tokenSecret);

        Query query = new Query("source:twitter4j yusukey");
        QueryResult result =;
        for (Status status : result.getTweets()) {"@" + status.getUser().getScreenName() + ":" + status.getText());
	} catch (Exception e) {


I am facing the same problem :frowning:


I have also the same problem. But what is strange is that the code running on my server seems to work : is updated as it should.
But when I try to run excactly the same code in my dev environment I get an 401 error. It was working yesterday.
I use VB.NET. Here is how I connect,btw.

Dim encode As Encoding = Encoding.GetEncoding(“utf-8”)

    Dim url As String = ",pepsi,coca-cola,rccola"
        Dim request As WebRequest = WebRequest.Create(url)
    request.Credentials = New NetworkCredential("xxxxx", "xxxxxx")
        Dim WebResponse = request.GetResponse()

        Dim responseStream = New StreamReader(WebResponse.GetResponseStream(), encode)

        'JSON Parse

        While Not responseStream.EndOfStream

            Dim json As String = responseStream.ReadLine()
            If json.Length <> 0 Then
            End If
        End While