List of usage examples for twitter4j Twitter showStatus
Status showStatus(long id) throws TwitterException;
From source file:de.vanita5.twittnuker.util.Utils.java
License:Open Source License
public static ParcelableStatus findStatus(final Context context, final long account_id, final long status_id) throws TwitterException { if (context == null || account_id <= 0 || status_id <= 0) return null; final ParcelableStatus p_status = findStatusInDatabases(context, account_id, status_id); if (p_status != null) return p_status; final Twitter twitter = getTwitterInstance(context, account_id, true); if (twitter == null) return null; final Status status = twitter.showStatus(status_id); if (status == null || status.getId() <= 0) return null; final String where = Statuses.ACCOUNT_ID + " = " + account_id + " AND " + Statuses.STATUS_ID + " = " + status.getId();//from w w w .j av a2 s . c o m final ContentResolver resolver = context.getContentResolver(); resolver.delete(CachedStatuses.CONTENT_URI, where, null); resolver.insert(CachedStatuses.CONTENT_URI, ContentValuesCreator.makeStatusContentValues(status, account_id)); return new ParcelableStatus(status, account_id, false); }
From source file:dhbw.clippinggorilla.external.twitter.TwitterUtils.java
public static Article getArticleFromTwitter(long id) { try {//from w w w . j a v a 2s .c o m config(); // The factory instance is re-useable and thread safe. Twitter twitter = tf.getInstance(); Status status = twitter.showStatus(id); return fillArticle(status); } catch (TwitterException ex) { Log.error("Tweet not found", ex); } return null; }
From source file:org.apache.nutch.protocol.http.api.HttpBase.java
License:Apache License
private HttpResponse getTwitterResponse(String url) throws MalformedURLException, TwitterException, UnsupportedEncodingException, CharacterCodingException { url = URLDecoder.decode(url, "UTF-8"); Map<String, String> map = getQueryParams(url); String consumerKey = map.get("consumer_key"); String consumerSecret = map.get("consumer_secret"); String accessToken = map.get("oauth_key"); String accessTokenSecret = map.get("oauth_secret"); Twitter twitter = getTwitterInstance(consumerKey, consumerSecret, accessToken, accessTokenSecret); Paging paging = new Paging(); paging.setCount(10);//from www.j a v a2 s . c o m twitter4j.internal.http.HttpResponse twitterResponse; String result = null; if (!(url.indexOf("statuses/show.json") >= 0)) { String max_id = map.get("max_id"); if (null != max_id) paging.setMaxId(Long.parseLong(max_id)); ResponseList<Status> homeTimeline = twitter.getUserTimeline(paging); twitterResponse = homeTimeline.getResponse(); result = twitterResponse.asJSONArray().toString(); } else { String id = map.get("id"); Long statusId = Long.parseLong(id); Status status = twitter.showStatus(statusId); twitterResponse = status.getResponse(); result = twitterResponse.asJSONObject().toString(); } u = new URL(twitterResponse.getRequestURL()); code = twitterResponse.getStatusCode(); ByteBuffer buffer = toByteBUffer(result); contents = buffer.array(); contentType = "text/javascript"; headers = new SpellCheckedMetadata(); Map<String, List<String>> responseHeaders = twitterResponse.getResponseHeaderFields(); for (String key : responseHeaders.keySet()) { List<String> values = responseHeaders.get(key); for (String value : values) { if (null == key) continue; if (null == value) continue; headers.add(key, value); } } return null; }
From source file:org.getlantern.firetweet.util.Utils.java
License:Open Source License
@NonNull public static ParcelableStatus findStatus(final Context context, final long accountId, final long statusId) throws TwitterException { if (context == null) throw new NullPointerException(); final ParcelableStatus cached = findStatusInDatabases(context, accountId, statusId); if (cached != null) return cached; final Twitter twitter = getTwitterInstance(context, accountId, true); if (twitter == null) throw new TwitterException("Account does not exist"); final Status status = twitter.showStatus(statusId); final String where = Expression.and(Expression.equals(Statuses.ACCOUNT_ID, accountId), Expression.equals(Statuses.STATUS_ID, statusId)).getSQL(); final ContentResolver resolver = context.getContentResolver(); resolver.delete(CachedStatuses.CONTENT_URI, where, null); resolver.insert(CachedStatuses.CONTENT_URI, ContentValuesCreator.createStatus(status, accountId)); return new ParcelableStatus(status, accountId, false); }
From source file:twitter4j.examples.tweets.ShowStatus.java
License:Apache License
/** * Usage: java twitter4j.examples.tweets.ShowStatus [status id] * * @param args message/*from w ww . j a va2 s . co m*/ */ public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: java twitter4j.examples.tweets.ShowStatus [status id]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); Status status = twitter.showStatus(Long.parseLong(args[0])); System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText()); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to show status: " + te.getMessage()); System.exit(-1); } }