I am working on twitter, I have access token and I am also getting the tweets now I want to reply on that tweets like we did in Twitter website for this I am using the below code but it's not reply to the tweet but it updates my status please help me to solve this issue Thanks..
public void tweetReply() {
try {
// System.out.println("Post Id= " + itemsObj.postId);
AccessToken a = new AccessToken(twittertokens[0], twittertokens[1]);
Twitter twitter = new TwitterFactory().getInstance();
twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET);
twitter.setOAuthAccessToken(a);
Long id = new Long("236178766597087234");
twitter.updateStatus(new StatusUpdate("@lalitrajput024 this is to test For reply option ").inReplyToStatusId(id));
} catch (Exception e) {
// TODO: handle exception
}
}
I also had this problem and then i tried having the handler in the text itself.Now it seems to be working.
public static void reply(long inReplyToStatusId,String text,double latitude,double longitude,TwitterFactory factory) throws TwitterException
{ AccessToken accessToken = loadAccessToken();
Twitter twitter = factory.getInstance();
twitter.setOAuthConsumer(consumerKey, consumerSecrate);
twitter.setOAuthAccessToken(accessToken);
StatusUpdate stat= new StatusUpdate(text);
stat.setInReplyToStatusId(inReplyToStatusId);
GeoLocation location= new GeoLocation(latitude, longitude);
stat.setLocation(location);
twitter.updateStatus(stat);
}'
and i called it like
reply(238912922250792960l, "@praveena_kd testing reply", 12.787, 77.7578, factory);
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