List of usage examples for twitter4j Status getText
String getText();
From source file:org.minesales.infres6.narvisAPITwiterConsole.communications.twitter.input.TwitterInput.java
private String[] tweetParser(Status status) { String[] returnValue = new String[2]; returnValue[0] = getCleanTweet(status.getText()); returnValue[1] = status.getUser().getScreenName() + getOtherResponseName(status.getText()); return returnValue; }
From source file:org.mule.twitter.automation.TwitterTestUtils.java
License:Open Source License
public static boolean isStatusTextOnTimeline(ResponseList<Status> statusList, String statusText) { Status status; boolean found = false; Iterator<Status> iter = statusList.iterator(); while (iter.hasNext() && found == false) { status = iter.next();/*from www . ja va 2 s . c o m*/ if (status.getText().contains(statusText)) { found = true; } } return found; }
From source file:org.mule.twitter.automation.TwitterTestUtils.java
License:Open Source License
public static String getStatusTextOnTimeline(ResponseList<Status> statusList, long statusId) { Status status; boolean found = false; Iterator<Status> iter = statusList.iterator(); while (iter.hasNext() && found == false) { status = iter.next();// w w w.j ava 2 s . c om if (status.getId() == statusId) { return status.getText(); } } return null; }
From source file:org.mule.twitter.automation.TwitterTestUtils.java
License:Open Source License
public static String getStatusTextOnResponseList(ResponseList<Status> statusList, long statusId) { Status status; String statusText = ""; boolean found = false; Iterator<Status> iter = statusList.iterator(); while (iter.hasNext() && found == false) { status = iter.next();// www .j av a 2 s . co m if (status.getId() == statusId) { statusText = status.getText(); found = true; } } return statusText; }
From source file:org.mule.twitter.automation.TwitterTestUtils.java
License:Open Source License
public static long getIdForStatusTextOnResponseList(ResponseList<Status> statusList, String statusText) { Status status; long statusId = 0; boolean found = false; Iterator<Status> iter = statusList.iterator(); while (iter.hasNext() && found == false) { status = iter.next();//from w w w .jav a2 s . c o m if (status.getText().contains(statusText)) { statusId = status.getId(); found = true; } } return statusId; }
From source file:org.n52.twitter.model.TwitterMessage.java
License:Open Source License
public static TwitterMessage create(Status tweet) { if (isGeolocated(tweet)) { TwitterMessage result = new TwitterMessage(); result.id = Long.toString(tweet.getId()); result.procedure = new Procedure(tweet.getUser().getScreenName(), String.format(USER_URL, tweet.getUser().getScreenName())); result.location = new TwitterLocation(tweet.getGeoLocation(), tweet.getPlace()); result.createdTime = new DateTime(tweet.getCreatedAt(), DateTimeZone.UTC); result.link = String.format(TWEET_URL, tweet.getUser().getScreenName(), Long.toString(tweet.getId())); result.message = tweet.getText(); return result; }// w w w . jav a 2s. c o m return null; }
From source file:org.nsoft.openbus.model.Mensagem.java
License:Open Source License
public static Mensagem creteFromTwitterStatus(Status s) { try {//from w ww . j a v a2s .co m Mensagem mensagem = new Mensagem(); String text = s.getText(); for (HashtagEntity h : s.getHashtagEntities()) { String subText = "<a href=\"twitter_search://do_search?search=" + h.getText() + "\">#" + h.getText() + "</a>"; text = text.replace("#" + h.getText(), subText); } for (UserMentionEntity u : s.getUserMentionEntities()) { String subText = "<a href=\"twitter_search_user://find_user?username=" + u.getScreenName() + "\">@" + u.getScreenName() + "</a>"; text = text.replace("@" + u.getScreenName(), subText); } mensagem.setAction(OpenTwitterStatusAction.getInstance()); mensagem.addtions = createAddtions(s); mensagem.addtions.put("htmlText", text); mensagem.idMensagem = Long.toString(s.getId()); mensagem.nome_usuario = s.getUser().getName(); mensagem.mensagem = s.getText(); mensagem.imagePath = new URL(s.getUser().getOriginalProfileImageURL()); mensagem.data = s.getCreatedAt(); mensagem.idUser = s.getUser().getId(); mensagem.tipo = TIPO_STATUS; return mensagem; } catch (JSONException e) { return null; } catch (MalformedURLException e) { return null; } }
From source file:org.onebusaway.admin.service.impl.TwitterServiceImpl.java
License:Apache License
public String updateStatus(String statusMessage) throws IOException { if (statusMessage == null) { _log.info("nothing to tweet! Exiting"); return null; }//from w w w. j a v a2 s.c o m Map<String, String> params = new HashMap<>(); _log.info("tweeting: " + statusMessage); params.put("status", statusMessage); if (_twitter == null) { throw new IOException("Invalid Configuration: Missing consumer / access keys in spring configuration"); } String response = null; try { Status status = _twitter.updateStatus(statusMessage); if (status != null) { response = "Successfully tweeted \"" + status.getText() + "\" at " + status.getCreatedAt(); } } catch (TwitterException te) { _log.error(te.getExceptionCode() + ":" + ":" + te.getStatusCode() + te.getErrorMessage()); throw new IOException(te); } return response; }
From source file:org.onepercent.utils.twitterstream.agent.src.main.java.com.cloudera.flume.source.TwitterSource.java
License:Apache License
/** * Start processing events. This uses the Twitter Streaming API to sample * Twitter, and process tweets./*from ww w . jav a2s . com*/ */ @Override public void start() { // The channel is the piece of Flume that sits between the Source and Sink, // and is used to process events. final ChannelProcessor channel = getChannelProcessor(); final Map<String, String> headers = new HashMap<String, String>(); // The StatusListener is a twitter4j API, which can be added to a Twitter // stream, and will execute methods every time a message comes in through // the stream. StatusListener listener = new StatusListener() { // The onStatus method is executed every time a new tweet comes in. public void onStatus(Status status) { // The EventBuilder is used to build an event using the headers and // the raw JSON of a tweet logger.debug(status.getUser().getScreenName() + ": " + status.getText()); headers.put("timestamp", String.valueOf(status.getCreatedAt().getTime())); Event event = EventBuilder.withBody(DataObjectFactory.getRawJSON(status).getBytes(), headers); channel.processEvent(event); } // This listener will ignore everything except for new tweets public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) { } public void onTrackLimitationNotice(int numberOfLimitedStatuses) { } public void onScrubGeo(long userId, long upToStatusId) { } public void onException(Exception ex) { } public void onStallWarning(StallWarning warning) { } }; logger.debug("Setting up Twitter sample stream using consumer key {} and" + " access token {}", new String[] { consumerKey, accessToken }); // Set up the stream's listener (defined above), twitterStream.addListener(listener); // Set up a filter to pull out industry-relevant tweets if (keywords.length == 0) { logger.debug("Starting up Twitter sampling..."); twitterStream.sample(); } else if (keywords.length > 0) { if (languages.length == 0) { logger.debug("Starting up Twitter Keyword filtering..."); FilterQuery query = new FilterQuery().track(keywords); twitterStream.filter(query); } else { logger.debug("Starting up Twitter Keyword and Language filtering..."); FilterQuery query = new FilterQuery(); query.track(keywords); query.language(languages); twitterStream.filter(query); } } super.start(); }
From source file:org.openhab.action.twitter.internal.Twitter.java
License:Open Source License
/** * Sends a Tweet via Twitter// w w w . j a v a 2 s .c o m * * @param tweetTxt the Tweet to send * * @return <code>true</code>, if sending the tweet has been successful and * <code>false</code> in all other cases. */ @ActionDoc(text = "Sends a Tweet via Twitter", returns = "<code>true</code>, if sending the tweet has been successful and <code>false</code> in all other cases.") public static boolean sendTweet(@ParamDoc(name = "tweetTxt", text = "the Tweet to send") String tweetTxt) { if (!TwitterActionService.isProperlyConfigured) { logger.debug("Twitter client is not yet configured > execution aborted!"); return false; } if (!isEnabled) { logger.debug("Twitter client is disabled > execution aborted!"); return false; } try { // abbreviate the Tweet to meet the 140 character limit ... tweetTxt = StringUtils.abbreviate(tweetTxt, CHARACTER_LIMIT); // send the Tweet Status status = client.updateStatus(tweetTxt); logger.debug("Successfully sent Tweet '{}'", status.getText()); return true; } catch (TwitterException e) { logger.error("Failed to send Tweet '" + tweetTxt + "' because of: " + e.getLocalizedMessage()); return false; } }