How can I get the tweets when I have the tweet ID and the user ID ? I have a file containing lines like :
userID  tweetID
I guess I should go by :
Query query = new Query("huh ?");
QueryResult result = twitter.search(query);
List<Status> tweets = result.getTweets();
but I have no clue how to spell the query
Thanks
You don't need to use the API or know the user account. Just drop it into the following URL format, where XXXXXXXXX is the tweet id. Show activity on this post.
Today, Twitter IDs are unique 64-bit unsigned integers, which are based on time, instead of being sequential. The full ID is composed of a timestamp, a worker number, and a sequence number.
Well it was no search call. The tweet apparently is called Status and the code to retrieve one by ID is :
    final Twitter twitter = new TwitterFactory().getInstance();
    twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_KEY_SECRET);
    AccessToken accessToken = new AccessToken(TWITTER_TOKEN,
            TWITTER_TOKEN_SECRET);
    twitter.setOAuthAccessToken(accessToken);
    try {
        Status status = twitter.showStatus(Long.parseLong(tweetID));
        if (status == null) { // 
            // don't know if needed - T4J docs are very bad
        } else {
            System.out.println("@" + status.getUser().getScreenName()
                        + " - " + status.getText());
        }
    } catch (TwitterException e) {
        System.err.print("Failed to search tweets: " + e.getMessage());
        // e.printStackTrace();
        // DON'T KNOW IF THIS IS THROWN WHEN ID IS INVALID
    }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With