use of org.springframework.social.twitter.api.StatusDetails in project Gemma by PavlidisLab.
the class TwitterOutboundImpl method sendManualTweet.
@Override
@Secured({ "GROUP_ADMIN" })
public void sendManualTweet(String feed) {
TwitterOutboundImpl.log.debug("Checking if Twitter is enabled");
if (!Settings.getBoolean("gemma.twitter.enabled")) {
TwitterOutboundImpl.log.info("Twitter is disabled.");
return;
}
if (StringUtils.isNotBlank(feed)) {
TwitterOutboundImpl.log.info("Sending out tweet: '" + feed + "'");
String consumerKey = Settings.getString("twitter.consumer-key");
String consumerSecret = Settings.getString("twitter.consumer-secret");
String accessToken = Settings.getString("twitter.access-token");
String accessTokenSecret = Settings.getString("twitter.access-token-secret");
Twitter twitter = new TwitterTemplate(consumerKey, consumerSecret, accessToken, accessTokenSecret);
StatusDetails metadata = new StatusDetails();
metadata.setWrapLinks(true);
try {
Tweet tweet = twitter.timelineOperations().updateStatus(feed, metadata);
TwitterOutboundImpl.log.info("tweet info:" + tweet.toString());
} catch (Exception e) {
TwitterOutboundImpl.log.info(e.toString());
e.printStackTrace();
}
}
}
use of org.springframework.social.twitter.api.StatusDetails in project Gemma by PavlidisLab.
the class TwitterOutboundImpl method sendDailyFeed.
@Override
@Secured({ "GROUP_AGENT" })
public void sendDailyFeed() {
TwitterOutboundImpl.log.debug("Checking if Twitter is enabled");
if (!TwitterOutboundImpl.enabled.get()) {
return;
}
String feed = this.generateDailyFeed();
TwitterOutboundImpl.log.info("Twitter is enabled. Checking if Twitter feed is empty.");
if (StringUtils.isNotBlank(feed)) {
TwitterOutboundImpl.log.info("Sending out tweet: '" + feed + "'");
String consumerKey = Settings.getString("twitter.consumer-key");
String consumerSecret = Settings.getString("twitter.consumer-secret");
String accessToken = Settings.getString("twitter.access-token");
String accessTokenSecret = Settings.getString("twitter.access-token-secret");
Twitter twitter = new TwitterTemplate(consumerKey, consumerSecret, accessToken, accessTokenSecret);
StatusDetails metadata = new StatusDetails();
metadata.setWrapLinks(true);
try {
Tweet tweet = twitter.timelineOperations().updateStatus(feed, metadata);
TwitterOutboundImpl.log.info("tweet info:" + tweet.toString());
} catch (Exception e) {
TwitterOutboundImpl.log.info(e.toString());
}
}
}
Aggregations