List of usage examples for twitter4j Twitter retweetStatus
Status retweetStatus(long statusId) throws TwitterException;
From source file:org.wso2.carbon.connector.twitter.TwitterRetweetStatus.java
License:Open Source License
public void connect(MessageContext messageContext) throws ConnectException { try {//from w w w .j a v a2 s . c o m String id = TwitterUtils.lookupTemplateParamater(messageContext, ID); Twitter twitter = new TwitterClientLoader(messageContext).loadApiClient(); Status status = twitter.retweetStatus(Long.parseLong(id)); TwitterUtils.storeResponseStatus(messageContext, status); if (log.isDebugEnabled()) { log.info("@" + status.getUser().getScreenName() + " - " + status.getText()); } } catch (TwitterException te) { log.error("Failed to retweet status: " + te.getMessage(), te); TwitterUtils.storeErrorResponseStatus(messageContext, te); } }
From source file:twitter4j.examples.tweets.RetweetStatus.java
License:Apache License
/** * Usage: java twitter4j.examples.tweets.RetweetStatus [status id] * * @param args message// w w w . j av a 2 s . co m */ public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: java twitter4j.examples.tweets.RetweetStatus [status id]"); System.exit(-1); } System.out.println("Retweeting the status id - [" + args[0] + "]."); try { Twitter twitter = new TwitterFactory().getInstance(); twitter.retweetStatus(Long.parseLong(args[0])); System.out.println("Successfully retweeted status [" + args[0] + "]."); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to retweet: " + te.getMessage()); System.exit(-1); } }
From source file:twitterbot.example.tweet.RetweetMethods.java
static public void RetweetTweet(String id) { try {//w ww .ja v a 2s. c o m String consumerKey = ""; // key obtained after registering app. String consumerSecret = ""; // secret key obtained from the registered app. String twitterToken = ""; // access_token received by authentication user's twitter account String twitterSecret = ""; // access_secret obtained by authentication user's twitter account String tweetId = id; //messageId of the tweet to be retweeted Twitter factory = new TwitterFactory().getInstance(); Twitter twitter = factory; twitter.setOAuthConsumer(consumerKey, consumerSecret); AccessToken accessToken = new AccessToken(twitterToken, twitterSecret); twitter.setOAuthAccessToken(accessToken); twitter.retweetStatus(Long.valueOf(tweetId)); } catch (Exception ex) { System.out.println("Error: " + ex.getMessage()); } }