Search code examples
javatwitter4jtwitter-streaming-api

twitter4j Streaming Api not showing result when search "@sometext"


twitter4j Streaming Api not showing result when search "@sometext" here is code please help. first i am initializing the authentication then creating the listener. after assigning the listener just implement filter and show result from listener.

    public static void main(String[] args) throws TwitterException {



    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true);
    cb.setOAuthConsumerKey(ConsumerKey);
    cb.setOAuthConsumerSecret(ConsumerSecret);
    cb.setOAuthAccessToken(AccessToken);
    cb.setOAuthAccessTokenSecret(AccessSecret);
    TwitterStream twitterStream = new TwitterStreamFactory(cb.build()).getInstance();

     RawStreamListener listener = new RawStreamListener() {
        @Override
        public void onMessage(String rawJSON) {
            System.out.println(rawJSON);
        }

        @Override
        public void onException(Exception ex) {
            ex.printStackTrace();
        }
    };

    FilterQuery fq = new FilterQuery();

    String keywords[] = {"@convo"};

    fq.track(keywords);

    twitterStream.addListener(listener);
    twitterStream.filter(fq);
}

i am trying to get the post which have some "@convo" tag if i search without "@" its work good but when i use @ in query it dose not show result.

thankyou.


Solution

  • i searched and find twitter streaming api dose not support @ search or filter here is detail

    follow

    Available on POST statuses/filter.

    A comma-separated list of user IDs, indicating the users whose Tweets should be delivered on the stream. Following protected users is not supported. For each user specified, the stream will contain:

    Tweets created by the user. Tweets which are retweeted by the user. Replies to any Tweet created by the user. Retweets of any Tweet created by the user. Manual replies, created without pressing a reply button (e.g. “@twitterapi I agree”). The stream will not contain:

    Tweets mentioning the user (e.g. “Hello @twitterapi!”). Manual Retweets created without pressing a Retweet button (e.g. “RT @twitterapi The API is great”). Tweets by protected users. https://dev.twitter.com/docs/streaming-apis/parameters