mstfky
mstfky

Reputation: 87

Twitter4j Getting Tweets Too Long

Hello i have tweet id's and i saved them to database before. But i saw that i could not save created time efficiently (it is saved like 00:00:00). Therefore i wished to update my tweets with tweet id by using following code.

   MyConnectionBuilder myConnection = new MyConnectionBuilder();
   Twitter twitter = new TwitterFactory(myConnection.configuration.build()).getInstance();
    Status status = twitter.showStatus(Long.parseLong(tweetId));

But it takes too much time to get tweets, is there any rate limit for this ? If there is a rate limit how can i make it faster ?

Upvotes: 0

Views: 146

Answers (1)

rzo1
rzo1

Reputation: 5751

Updating every single tweet via showStatus wastes your "credits" for a given timeframe (rate-limit).

For updating multiple tweets, you should use lookup with a maximum of 100 ids per request. This call will use the /statuses/lookup endpoint.

Rate-Limit and endpoint documentation can be found here

Code-Snipped for it:

Twitter twitter =  twitterFactory.getInstance();
ResponseList<Status> responseList  = twitter.lookup(ArrayUtils.toPrimitive(ids));

    if(responseList != null) {
        for (Status status : responseList) {
            // do what you need to do here

        }
    }       

Upvotes: 1

Related Questions