List of usage examples for twitter4j StatusUpdate inReplyToStatusId
long inReplyToStatusId
To view the source code for twitter4j StatusUpdate inReplyToStatusId.
Click Source Link
From source file:com.javielinux.api.loaders.UploadStatusLoader.java
License:Apache License
private boolean updateText(String text, long tweet_id, boolean useGeo) { StatusUpdate statusUpdate = new StatusUpdate(text); if (useGeo) { Location loc = LocationUtils.getLastLocation(getContext()); GeoLocation gl = new GeoLocation(loc.getLatitude(), loc.getLongitude()); statusUpdate.setLocation(gl);//from ww w . ja v a 2 s .co m } if (tweet_id > 0) statusUpdate.inReplyToStatusId(tweet_id); try { twitter.updateStatus(statusUpdate); } catch (TwitterException e) { e.printStackTrace(); return false; } catch (Exception e) { e.printStackTrace(); return false; } return true; }
From source file:com.javielinux.api.loaders.UploadTwitlongerLoader.java
License:Apache License
@Override public BaseResponse loadInBackground() { //TODO: Comprobar el valor devuelto con el valor esperado (error - ready) y el parmetro user_geolocation try {//from w ww.j a va2s . c o m Log.d(Utils.TAG, "Enviando a twitlonger: " + tweet_text); String textTwitLonger = ""; HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://www.twitlonger.com/api_post"); try { List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(4); nameValuePairs.add(new BasicNameValuePair("application", "tweettopics")); nameValuePairs.add(new BasicNameValuePair("api_key", "f7y8lgz31srR46sr")); nameValuePairs.add(new BasicNameValuePair("username", twitter.getScreenName())); nameValuePairs.add(new BasicNameValuePair("message", tweet_text)); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8")); HttpResponse httpResponse = httpclient.execute(httppost); String xml = EntityUtils.toString(httpResponse.getEntity()); XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); XmlPullParser x = factory.newPullParser(); x.setInput(new StringReader(xml)); String error = ""; int eventType = x.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG) { if (x.getName().equals("error")) { error = x.nextText(); } if (x.getName().equals("content")) { textTwitLonger = x.nextText(); Log.d(Utils.TAG, "Enviando a twitter: " + textTwitLonger); } } eventType = x.next(); } if (!error.equals("")) { Log.d(Utils.TAG, "Error: " + error); ErrorResponse response = new ErrorResponse(); response.setError(error); return response; } } catch (Exception e) { e.printStackTrace(); ErrorResponse response = new ErrorResponse(); response.setError(e, e.getMessage()); return response; } UploadTwitlongerResponse response = new UploadTwitlongerResponse(); if (!textTwitLonger.equals("")) { StatusUpdate statusUpdate = new StatusUpdate(textTwitLonger); if (use_geolocation) { Location loc = LocationUtils.getLastLocation(getContext()); GeoLocation gl = new GeoLocation(loc.getLatitude(), loc.getLongitude()); statusUpdate.setLocation(gl); } if (tweet_id > 0) statusUpdate.inReplyToStatusId(tweet_id); twitter.updateStatus(statusUpdate); response.setReady(true); } else { response.setReady(false); } return response; } catch (Exception e) { e.printStackTrace(); ErrorResponse response = new ErrorResponse(); response.setError(e, e.getMessage()); return response; } }
From source file:com.javielinux.task.UploadStatusAsyncTask.java
License:Apache License
private boolean updateText(String text, long tweet_id, boolean useGeo) { StatusUpdate su = new StatusUpdate(text); if (useGeo) { Location loc = LocationUtils.getLastLocation(mContext); GeoLocation gl = new GeoLocation(loc.getLatitude(), loc.getLongitude()); su.setLocation(gl);/*from w w w . j a v a2s. c o m*/ } if (tweet_id > 0) su.inReplyToStatusId(tweet_id); try { twitter.updateStatus(su); } catch (TwitterException e) { e.printStackTrace(); return false; } catch (Exception e) { e.printStackTrace(); return false; } return true; }
From source file:com.javielinux.task.UploadTwitlongerAsyncTask.java
License:Apache License
@Override protected Boolean doInBackground(String... args) { try {//from w ww. jav a2s . c o m String text = args[0]; Log.d(Utils.TAG, "Enviando a twitlonger: " + text); long tweet_id = Long.parseLong(args[1]); boolean useGeo = args[2].equals("1") ? true : false; String textTwitLonger = ""; HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://www.twitlonger.com/api_post"); try { List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(4); nameValuePairs.add(new BasicNameValuePair("application", "tweettopics")); nameValuePairs.add(new BasicNameValuePair("api_key", "f7y8lgz31srR46sr")); nameValuePairs.add(new BasicNameValuePair("username", twitter.getScreenName())); //byte[] utf8Bytes = text.getBytes("UTF8"); //String textutf8 = new String(utf8Bytes, "UTF8"); nameValuePairs.add(new BasicNameValuePair("message", text)); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8")); HttpResponse httpResponse = httpclient.execute(httppost); String xml = EntityUtils.toString(httpResponse.getEntity()); try { XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); XmlPullParser x = factory.newPullParser(); x.setInput(new StringReader(xml)); String error = ""; int eventType = x.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG) { if (x.getName().equals("error")) { error = x.nextText(); } if (x.getName().equals("content")) { textTwitLonger = x.nextText(); Log.d(Utils.TAG, "Enviando a twitter: " + textTwitLonger); } } eventType = x.next(); } if (!error.equals("")) { Log.d(Utils.TAG, "Error: " + error); return true; } } catch (Exception e) { e.printStackTrace(); return true; } } catch (Exception e) { e.printStackTrace(); return true; } if (!textTwitLonger.equals("")) { StatusUpdate su = new StatusUpdate(textTwitLonger); if (useGeo) { Location loc = LocationUtils.getLastLocation(mContext); GeoLocation gl = new GeoLocation(loc.getLatitude(), loc.getLongitude()); su.setLocation(gl); } if (tweet_id > 0) su.inReplyToStatusId(tweet_id); twitter.updateStatus(su); } else { return true; } //} catch (TwitterException e) { // e.printStackTrace(); // return true; } catch (Exception e) { e.printStackTrace(); return true; } return false; }
From source file:com.learnncode.twitter.async.TweetActionAsync.java
License:Apache License
@Override protected Void doInBackground(Void... arg0) { try {/*ww w .j ava2 s .c o m*/ if (mActionType == ActionType.favorite) { mStatusObject.setTweetStatusObject( TwitterHelper.getTwitterInstance(mContext).createFavorite(mTweetId), mPosition, mActionType); } else if (mActionType == ActionType.unfavorite) { mStatusObject.setTweetStatusObject( TwitterHelper.getTwitterInstance(mContext).destroyFavorite(mTweetId), mPosition, mActionType); } else if (mActionType == ActionType.retweet) { mStatusObject.setTweetStatusObject( TwitterHelper.getTwitterInstance(mContext).retweetStatus(mTweetId), mPosition, mActionType); } else if (mActionType == ActionType.reply) { Twitter twitter = TwitterHelper.getTwitterInstance(mContext); StatusUpdate statusUpdate = new StatusUpdate(mReplyText); statusUpdate.inReplyToStatusId(mTweetId); mStatusObject.setTweetStatusObject(twitter.updateStatus(statusUpdate), mPosition, mActionType); } else if (mActionType == ActionType.tweet) { Twitter twitter = TwitterHelper.getTwitterInstance(mContext); StatusUpdate statusUpdate = new StatusUpdate(mReplyText); if (imageFile != null) { statusUpdate.setMedia(imageFile); } mStatusObject.setTweetStatusObject(twitter.updateStatus(statusUpdate), mPosition, mActionType); } } catch (Exception e) { mStatusObject.setTweetStatusObject(null, mPosition, mActionType); } return null; }
From source file:org.komusubi.feeder.sns.twitter.Twitter4j.java
License:Apache License
/** * tweet./*from w w w .ja v a 2s . co m*/ * @param message */ public void tweet(Message message) { Script current = new ScriptLine(""); try { Status result = null; for (Script script : message) { current = script; // mark current script for when exception occurred. if (outputConsole) { System.out.printf("tweet(length:%d): %s%n", TweetScript.lengthAfterTweeted(script.trimedLine()), script.trimedLine()); } else { StatusUpdate status = new StatusUpdate(script.trimedLine()); if (result != null) { status.inReplyToStatusId(result.getId()); } logger.info("tweet(length:{}): {}", TweetScript.lengthAfterTweeted(status.getStatus()), status.getStatus()); result = twitter.updateStatus(status); } } } catch (TwitterException e) { throw new Twitter4jException(String.format("tweet(length:%d): %s", TweetScript.lengthAfterTweeted(current.trimedLine()), current.trimedLine()), e); } }
From source file:org.springframework.integration.twitter.StatusUpdateSupport.java
License:Apache License
/** * {@link StatusUpdate} instances are used to drive status updates. * * @param message the inbound messages/*from w w w .j a va 2 s . c om*/ * @return a {@link StatusUpdate} that's been materialized from the inbound message * @throws Throwable thrown if something goes wrong */ public StatusUpdate fromMessage(Message<?> message) throws Throwable { Object payload = message.getPayload(); StatusUpdate statusUpdate = null; if (payload instanceof String) { statusUpdate = new StatusUpdate((String) payload); if (message.getHeaders().containsKey(TwitterHeaders.TWITTER_IN_REPLY_TO_STATUS_ID)) { Long replyId = (Long) message.getHeaders().get(TwitterHeaders.TWITTER_IN_REPLY_TO_STATUS_ID); if ((replyId != null) && (replyId > 0)) { statusUpdate.inReplyToStatusId(replyId); } } if (message.getHeaders().containsKey(TwitterHeaders.TWITTER_PLACE_ID)) { String placeId = (String) message.getHeaders().get(TwitterHeaders.TWITTER_PLACE_ID); if (StringUtils.hasText(placeId)) { statusUpdate.placeId(placeId); } } if (message.getHeaders().containsKey(TwitterHeaders.TWITTER_GEOLOCATION)) { GeoLocation geoLocation = (GeoLocation) message.getHeaders() .get(TwitterHeaders.TWITTER_GEOLOCATION); if (null != geoLocation) { statusUpdate.location(geoLocation); } } if (message.getHeaders().containsKey(TwitterHeaders.TWITTER_DISPLAY_COORDINATES)) { Boolean displayCoords = (Boolean) message.getHeaders() .get(TwitterHeaders.TWITTER_DISPLAY_COORDINATES); if (displayCoords != null) { statusUpdate.displayCoordinates(displayCoords); } } } if (payload instanceof StatusUpdate) { statusUpdate = (StatusUpdate) payload; } return statusUpdate; }
From source file:toninbot.ToninStatusListener.java
@Override public void onStatus(Status tweetRecibido) { if (tweetRecibido.getUser().getId() != 184742273L && tweetRecibido.getUser().getId() != 2841338087L) { return;//w w w .j ava2 s . co m } System.out.println(tweetRecibido.getUser().getName() + " " + tweetRecibido.getText()); Calendar cal = Calendar.getInstance(); cal.setTime(tweetRecibido.getCreatedAt()); long hora = cal.get(Calendar.HOUR_OF_DAY); System.out.println("Hora: " + cal.get(Calendar.HOUR_OF_DAY)); //comprobar la hora if (hora > 7 || hora < 1) { return; } //comprobar que no sea una respuesta a alguien if (tweetRecibido.getText().contains("@")) { return; } StatusUpdate stat = new StatusUpdate( "@" + tweetRecibido.getUser().getScreenName() + " " + respuestaRandom()); System.out.println("Fora de horario!"); stat.inReplyToStatusId(tweetRecibido.getId()); try { twitter.updateStatus(stat); System.out.println("Twitteado: " + stat.toString()); } catch (TwitterException ex) { System.out.println("Error"); } }
From source file:twit.Twit.java
public static void onStatus(Status status, int kode) { Twitter tf = new TwitterFactory().getInstance(); //kode 1 : Format benar if (kode == 1) { StatusUpdate st = new StatusUpdate("Hi @" + status.getUser().getScreenName() + ", terima kasih telah membantu monitoring harga Cabe Indonesia :D"); st.inReplyToStatusId(status.getId()); try {// ww w. j a va 2 s .c o m tf.updateStatus(st); } catch (TwitterException e) { // TODO Auto-generated catch block e.printStackTrace(); } //kode 2 : Format salah } else if (kode == 2) { StatusUpdate st = new StatusUpdate( "Hi @" + status.getUser().getScreenName() + ", terima kasih atas laporan Anda! :)"); st.inReplyToStatusId(status.getId()); try { tf.updateStatus(st); } catch (TwitterException e) { // TODO Auto-generated catch block e.printStackTrace(); } //kode 2 : Format salah } else { System.out.println("error"); } }