List of usage examples for twitter4j User getProfileImageURL
String getProfileImageURL();
From source file:com.dwdesign.tweetings.util.Utils.java
License:Open Source License
public static ContentValues makeAccountContentValues(final int color, final AccessToken access_token, final User user, final String rest_base_url, final String oauth_base_url, final String signing_rest_base_url, final String signing_oauth_base_url, final String search_base_url, final String upload_base_url, final String basic_password, final int auth_type) { if (user == null || user.getId() <= 0) return null; final ContentValues values = new ContentValues(); switch (auth_type) { case Accounts.AUTH_TYPE_TWIP_O_MODE: { break;//from w ww .j a va 2 s .co m } case Accounts.AUTH_TYPE_BASIC: { if (basic_password == null) return null; values.put(Accounts.BASIC_AUTH_PASSWORD, basic_password); break; } case Accounts.AUTH_TYPE_OAUTH: case Accounts.AUTH_TYPE_XAUTH: { if (access_token == null) return null; if (user.getId() != access_token.getUserId()) return null; values.put(Accounts.OAUTH_TOKEN, access_token.getToken()); values.put(Accounts.TOKEN_SECRET, access_token.getTokenSecret()); break; } } values.put(Accounts.AUTH_TYPE, auth_type); values.put(Accounts.USER_ID, user.getId()); values.put(Accounts.USERNAME, user.getScreenName()); values.put(Accounts.PROFILE_IMAGE_URL, user.getProfileImageURL().toString()); values.put(Accounts.USER_COLOR, color); values.put(Accounts.IS_ACTIVATED, 1); values.put(Accounts.REST_BASE_URL, rest_base_url); values.put(Accounts.SIGNING_REST_BASE_URL, signing_rest_base_url); values.put(Accounts.SEARCH_BASE_URL, search_base_url); values.put(Accounts.UPLOAD_BASE_URL, upload_base_url); values.put(Accounts.OAUTH_BASE_URL, oauth_base_url); values.put(Accounts.SIGNING_OAUTH_BASE_URL, signing_oauth_base_url); return values; }
From source file:com.dwdesign.tweetings.util.Utils.java
License:Open Source License
public static ContentValues makeCachedUserContentValues(final User user) { if (user == null || user.getId() <= 0) return null; final ContentValues values = new ContentValues(); values.put(CachedUsers.NAME, user.getName()); values.put(CachedUsers.PROFILE_IMAGE_URL, user.getProfileImageURL().toString()); values.put(CachedUsers.SCREEN_NAME, user.getScreenName()); values.put(CachedUsers.USER_ID, user.getId()); return values; }
From source file:com.dwdesign.tweetings.util.Utils.java
License:Open Source License
public static ContentValues makeDirectMessageContentValues(final DirectMessage message, final long account_id) { if (message == null || message.getId() <= 0) return null; final ContentValues values = new ContentValues(); final User sender = message.getSender(), recipient = message.getRecipient(); if (sender == null || recipient == null) return null; values.put(DirectMessages.ACCOUNT_ID, account_id); values.put(DirectMessages.MESSAGE_ID, message.getId()); values.put(DirectMessages.MESSAGE_TIMESTAMP, message.getCreatedAt().getTime()); values.put(DirectMessages.SENDER_ID, sender.getId()); values.put(DirectMessages.RECIPIENT_ID, recipient.getId()); values.put(DirectMessages.TEXT, message.getText()); values.put(DirectMessages.SENDER_NAME, sender.getName()); values.put(DirectMessages.SENDER_SCREEN_NAME, sender.getScreenName()); values.put(DirectMessages.RECIPIENT_NAME, recipient.getName()); values.put(DirectMessages.RECIPIENT_SCREEN_NAME, recipient.getScreenName()); final URL sender_profile_image_url = sender.getProfileImageURL(); final URL recipient_profile_image_url = recipient.getProfileImageURL(); if (sender_profile_image_url != null) { values.put(DirectMessages.SENDER_PROFILE_IMAGE_URL, sender_profile_image_url.toString()); }//from ww w . ja v a 2 s.c o m if (recipient_profile_image_url != null) { values.put(DirectMessages.RECIPIENT_PROFILE_IMAGE_URL, recipient_profile_image_url.toString()); } return values; }
From source file:com.dwdesign.tweetings.util.Utils.java
License:Open Source License
public static ContentValues makeStatusContentValues(Status status, final long account_id) { if (status == null || status.getId() <= 0) return null; final ContentValues values = new ContentValues(); values.put(Statuses.ACCOUNT_ID, account_id); values.put(Statuses.STATUS_ID, status.getId()); final boolean is_retweet = status.isRetweet(); final Status retweeted_status = is_retweet ? status.getRetweetedStatus() : null; if (retweeted_status != null) { final User retweet_user = status.getUser(); values.put(Statuses.RETWEET_ID, retweeted_status.getId()); values.put(Statuses.RETWEETED_BY_ID, retweet_user.getId()); values.put(Statuses.RETWEETED_BY_NAME, retweet_user.getName()); values.put(Statuses.RETWEETED_BY_SCREEN_NAME, retweet_user.getScreenName()); status = retweeted_status;/* w w w . ja v a 2 s.co m*/ } final User user = status.getUser(); if (user != null) { final long user_id = user.getId(); final String profile_image_url = user.getProfileImageURL().toString(); final String name = user.getName(), screen_name = user.getScreenName(); values.put(Statuses.USER_ID, user_id); values.put(Statuses.NAME, name); values.put(Statuses.SCREEN_NAME, screen_name); values.put(Statuses.IS_PROTECTED, user.isProtected() ? 1 : 0); values.put(Statuses.IS_VERIFIED, user.isVerified() ? 1 : 0); values.put(Statuses.PROFILE_IMAGE_URL, profile_image_url); } if (status.getCreatedAt() != null) { values.put(Statuses.STATUS_TIMESTAMP, status.getCreatedAt().getTime()); } values.put(Statuses.TEXT, formatStatusText(status)); values.put(Statuses.TEXT_PLAIN, status.getText()); values.put(Statuses.RETWEET_COUNT, status.getRetweetCount()); values.put(Statuses.IN_REPLY_TO_SCREEN_NAME, status.getInReplyToScreenName()); values.put(Statuses.IN_REPLY_TO_STATUS_ID, status.getInReplyToStatusId()); values.put(Statuses.SOURCE, status.getSource()); values.put(Statuses.IS_POSSIBLY_SENSITIVE, status.isPossiblySensitive()); final GeoLocation location = status.getGeoLocation(); if (location != null) { values.put(Statuses.LOCATION, location.getLatitude() + "," + location.getLongitude()); } values.put(Statuses.IS_RETWEET, is_retweet ? 1 : 0); values.put(Statuses.IS_FAVORITE, status.isFavorited() ? 1 : 0); return values; }
From source file:com.eventattend.portal.bl.TwitterBL.java
License:Open Source License
public TwitterDTO fetchProfile(User user, TwitterDTO twitterDTO) { System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); String userDesc = null;/*from w ww .ja va 2 s. c o m*/ String favCount = null; String followCount = null; String friendsCount = null; String location = null; String name = null; String profImgUrl = null; String personalUrl = null; String twitterURL = "http://twitter.com/" + user.getScreenName(); userDesc = user.getDescription(); favCount = String.valueOf(user.getFavouritesCount()); followCount = String.valueOf(user.getFollowersCount()); friendsCount = String.valueOf(user.getFriendsCount()); location = user.getLocation(); name = user.getName(); profImgUrl = String.valueOf(user.getProfileImageURL()); // System.out.println("User ID >> "+user.getId()); //System.out.println("TwitterA/C CreatedAt >> "+user.getCreatedAt()); System.out.println("Description >> " + user.getDescription()); System.out.println("FavouritesCount >> " + user.getFavouritesCount()); System.out.println("FollowersCoun >> " + user.getFollowersCount()); System.out.println("FriendsCount >> " + user.getFriendsCount()); System.out.println("Language >> " + user.getLang()); System.out.println("Location >> " + user.getLocation()); System.out.println("Name >> " + user.getName()); System.out.println("ProfileImageURL >> " + user.getProfileImageURL()); System.out.println("Total tweets >> " + user.getStatusesCount()); if (twitterURL != null) { twitterDTO.setUserURL(twitterURL); System.out.println("Twitter URL >> " + twitterURL); } if (userDesc != null && (!userDesc.equals(""))) { twitterDTO.setUserDesc(userDesc); } else { twitterDTO.setUserDesc(null); } if (favCount != null) { twitterDTO.setUserFavCount(favCount); } if (followCount != null) { twitterDTO.setFollowersCount(followCount); } if (friendsCount != null) { twitterDTO.setFriendsCount(friendsCount); } if (location != null) { twitterDTO.setUserLocation(location); } if (name != null) { twitterDTO.setUserName(name); } if (profImgUrl != null) { twitterDTO.setUserImg(profImgUrl); } if (user.getURL() != null) { if (!user.getURL().equals(twitterURL)) { personalUrl = String.valueOf(user.getURL()); System.out.println("Personal URL >> " + user.getURL()); twitterDTO.setPersonalUrl(personalUrl); } } // Status status=user.getStatus(); // System.out.println("Latest Tweet >> TweetId "+status.getId()+"|Tweet> "+status.getText()+" |via> "+status.getSource() // +"|Loc >"+status.getGeoLocation()+"|tweetTime >"+status.getCreatedAt()+"Place Details we can get >"+status.getPlace()); /*System.out.println("RateLimitStatus >> "+user.getRateLimitStatus()); System.out.println("ProfileBackgroundColor >> "+user.getProfileBackgroundColor()); System.out.println("ProfileBackgroundImageUrl >> "+user.getProfileBackgroundImageUrl()); System.out.println("ProfileLinkColor >> "+user.getProfileLinkColor()); System.out.println("ProfileSidebarBorderColor >> "+user.getProfileSidebarBorderColor()); System.out.println("user.getProfileSidebarFillColor() >> "+user.getProfileSidebarFillColor()); System.out.println("ProfileTextColor >> "+user.getProfileTextColor());*/ return twitterDTO; }
From source file:com.eventattend.portal.bl.TwitterBL.java
License:Open Source License
public TwitterDTO getProfileImageURL(AccessToken accessToken) throws BaseAppException { twitter.setOAuthAccessToken(accessToken); TwitterDTO twitterDTO = null;// w ww . j a v a 2 s . c o m twitterDTO = new TwitterDTO(); User user = null; try { user = twitter.showUser(twitter.getId()); URL url = user.getProfileImageURL(); } catch (TwitterException e) { // TODO Auto-generated catch block processTwitterException(e); } System.out.println(user.getName() + "<< >>" + user.getProfileImageURL()); if (user != null) { if (user.getProfileImageURL() != null) { System.out.println("TwitterImageURL=> " + user.getProfileImageURL()); twitterDTO.setUserImg(user.getProfileImageURL().toString()); } twitterDTO.setUserName(user.getName()); } return twitterDTO; }
From source file:com.eventattend.portal.bl.TwitterBL.java
License:Open Source License
public String profileImageURL(AccessToken accessToken) throws BaseAppException { twitter.setOAuthAccessToken(accessToken); TwitterDTO twitterDTO = null;/*w w w. j a v a2 s . c o m*/ twitterDTO = new TwitterDTO(); User user = null; String profileImgURL = null; try { user = twitter.showUser(twitter.getId()); URL url = user.getProfileImageURL(); } catch (TwitterException e) { processTwitterException(e); } if (user != null) { if (user.getProfileImageURL() != null) { System.out.println("TwitterImageURL=> " + user.getProfileImageURL()); profileImgURL = user.getProfileImageURL().toString(); } } return profileImgURL; }
From source file:com.eventattend.portal.bl.TwitterBL.java
License:Open Source License
public List tweets(Twitter twitter, String screenName, TwitterDTO twitterDTO) throws BaseAppException { List tweetList = new ArrayList(); List<Status> statuses = null; Paging paging = new Paging(1, 10); try {// w ww .ja va2 s .c o m statuses = twitter.getUserTimeline(screenName, paging); } catch (TwitterException e) { processTwitterException(e); } int i = 1; if (!statuses.isEmpty()) { for (Status status : statuses) { if (i <= 10) { User user = status.getUser(); twitterDTO = new TwitterDTO(); // // if(userId==status.getUser().getId()){ if (status.getId() != 0) { System.out.println(i + "TweetId=> " + status.getId()); twitterDTO.setTweetId(String.valueOf(status.getId())); } if (user.getProfileImageURL() != null) { twitterDTO.setUserImg(user.getProfileImageURL().toString()); } if (user.getScreenName() != null) { twitterDTO.setUserScreeName("http://twitter.com/" + user.getScreenName()); } if (user.getName() != null) { twitterDTO.setUserName(user.getName()); } if (status.getText() != null) { twitterDTO.setTweet(status.getText()); } System.out.println(status.getId() + " : " + status.getCreatedAt() + " >> " + status.getText()); tweetList.add(twitterDTO); i++; } else { break; } } } return tweetList; }
From source file:com.github.jcustenborder.kafka.connect.twitter.StatusConverter.java
License:Apache License
public static void convert(User user, Struct struct) { struct.put("Id", user.getId()).put("Name", user.getName()).put("ScreenName", user.getScreenName()) .put("Location", user.getLocation()).put("Description", user.getDescription()) .put("ContributorsEnabled", user.isContributorsEnabled()) .put("ProfileImageURL", user.getProfileImageURL()) .put("BiggerProfileImageURL", user.getBiggerProfileImageURL()) .put("MiniProfileImageURL", user.getMiniProfileImageURL()) .put("OriginalProfileImageURL", user.getOriginalProfileImageURL()) .put("ProfileImageURLHttps", user.getProfileImageURLHttps()) .put("BiggerProfileImageURLHttps", user.getBiggerProfileImageURLHttps()) .put("MiniProfileImageURLHttps", user.getMiniProfileImageURLHttps()) .put("OriginalProfileImageURLHttps", user.getOriginalProfileImageURLHttps()) .put("DefaultProfileImage", user.isDefaultProfileImage()).put("URL", user.getURL()) .put("Protected", user.isProtected()).put("FollowersCount", user.getFollowersCount()) .put("ProfileBackgroundColor", user.getProfileBackgroundColor()) .put("ProfileTextColor", user.getProfileTextColor()) .put("ProfileLinkColor", user.getProfileLinkColor()) .put("ProfileSidebarFillColor", user.getProfileSidebarFillColor()) .put("ProfileSidebarBorderColor", user.getProfileSidebarBorderColor()) .put("ProfileUseBackgroundImage", user.isProfileUseBackgroundImage()) .put("DefaultProfile", user.isDefaultProfile()) .put("ShowAllInlineMedia", user.isShowAllInlineMedia()).put("FriendsCount", user.getFriendsCount()) .put("CreatedAt", user.getCreatedAt()).put("FavouritesCount", user.getFavouritesCount()) .put("UtcOffset", user.getUtcOffset()).put("TimeZone", user.getTimeZone()) .put("ProfileBackgroundImageURL", user.getProfileBackgroundImageURL()) .put("ProfileBackgroundImageUrlHttps", user.getProfileBackgroundImageUrlHttps()) .put("ProfileBannerURL", user.getProfileBannerURL()) .put("ProfileBannerRetinaURL", user.getProfileBannerRetinaURL()) .put("ProfileBannerIPadURL", user.getProfileBannerIPadURL()) .put("ProfileBannerIPadRetinaURL", user.getProfileBannerIPadRetinaURL()) .put("ProfileBannerMobileURL", user.getProfileBannerMobileURL()) .put("ProfileBannerMobileRetinaURL", user.getProfileBannerMobileRetinaURL()) .put("ProfileBackgroundTiled", user.isProfileBackgroundTiled()).put("Lang", user.getLang()) .put("StatusesCount", user.getStatusesCount()).put("GeoEnabled", user.isGeoEnabled()) .put("Verified", user.isVerified()).put("Translator", user.isTranslator()) .put("ListedCount", user.getListedCount()).put("FollowRequestSent", user.isFollowRequestSent()); List<String> withheldInCountries = new ArrayList<>(); if (null != user.getWithheldInCountries()) { for (String s : user.getWithheldInCountries()) { withheldInCountries.add(s);//from ww w .j a va 2s. co m } } struct.put("WithheldInCountries", withheldInCountries); }
From source file:com.javielinux.api.loaders.LoadMoreTweetDownLoader.java
License:Apache License
@Override public BaseResponse loadInBackground() { try {//from w w w . j a v a 2 s .c om LoadMoreTweetDownResponse response = new LoadMoreTweetDownResponse(); PreferenceManager.setDefaultValues(getContext(), R.xml.preferences, false); SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getContext()); int maxDownloadTweet = Integer.parseInt(pref.getString("prf_n_max_download", "60")); if (maxDownloadTweet <= 0) maxDownloadTweet = 60; ConnectionManager.getInstance().open(getContext()); Twitter twitter = ConnectionManager.getInstance().getTwitter(request.getUserId()); Paging p = new Paging(); p.setCount(maxDownloadTweet); p.setSinceId(request.getSinceId()); p.setMaxId(request.getMaxId()); ResponseList<Status> statii = null; try { statii = twitter.getHomeTimeline(p); } catch (OutOfMemoryError e) { e.printStackTrace(); } boolean breakTimeline = false; if (statii != null && statii.size() >= maxDownloadTweet - 10) { p = new Paging(1, 10); p.setSinceId(request.getSinceId()); p.setMaxId(statii.get(statii.size() - 1).getId()); if (twitter.getHomeTimeline().size() > 0) { breakTimeline = true; response.setHasMoreTweets(true); } } if (statii != null) { if (statii.size() > 0) { try { DataFramework.getInstance().open(getContext(), Utils.packageName); } catch (Exception e) { e.printStackTrace(); } List<InfoTweet> tweets = new ArrayList<InfoTweet>(); for (Status status : statii) { tweets.add(new InfoTweet(status)); } response.setTweets(tweets); long nextId = 1; Cursor c = DataFramework.getInstance().getCursor("tweets_user", new String[] { DataFramework.KEY_ID }, null, null, null, null, DataFramework.KEY_ID + " desc", "1"); if (!c.moveToFirst()) { c.close(); nextId = 1; } else { long Id = c.getInt(0) + 1; c.close(); nextId = Id; } try { boolean isFirst = true; for (int i = statii.size() - 1; i >= 0; i--) { User u = statii.get(i).getUser(); if (u != null) { ContentValues args = new ContentValues(); args.put(DataFramework.KEY_ID, "" + nextId); args.put("type_id", TweetTopicsUtils.TWEET_TYPE_TIMELINE); args.put("user_tt_id", "" + request.getUserId()); if (u.getProfileImageURL() != null) { args.put("url_avatar", u.getProfileImageURL().toString()); } else { args.put("url_avatar", ""); } args.put("username", u.getScreenName()); args.put("fullname", u.getName()); args.put("user_id", "" + u.getId()); args.put("tweet_id", Utils.fillZeros("" + statii.get(i).getId())); args.put("source", statii.get(i).getSource()); args.put("to_username", statii.get(i).getInReplyToScreenName()); args.put("to_user_id", "" + statii.get(i).getInReplyToUserId()); args.put("date", String.valueOf(statii.get(i).getCreatedAt().getTime())); if (statii.get(i).getRetweetedStatus() != null) { args.put("is_retweet", 1); args.put("retweet_url_avatar", statii.get(i).getRetweetedStatus().getUser() .getProfileImageURL().toString()); args.put("retweet_username", statii.get(i).getRetweetedStatus().getUser().getScreenName()); args.put("retweet_source", statii.get(i).getRetweetedStatus().getSource()); String t = Utils.getTwitLoger(statii.get(i).getRetweetedStatus()); if (t.equals("")) { args.put("text", statii.get(i).getRetweetedStatus().getText()); args.put("text_urls", Utils.getTextURLs(statii.get(i).getRetweetedStatus())); } else { args.put("text", t); } args.put("is_favorite", 0); } else { String t = Utils.getTwitLoger(statii.get(i)); if (t.equals("")) { args.put("text", statii.get(i).getText()); args.put("text_urls", Utils.getTextURLs(statii.get(i))); } else { args.put("text", t); } if (statii.get(i).isFavorited()) { args.put("is_favorite", 1); } } if (statii.get(i).getGeoLocation() != null) { args.put("latitude", statii.get(i).getGeoLocation().getLatitude()); args.put("longitude", statii.get(i).getGeoLocation().getLongitude()); } args.put("reply_tweet_id", statii.get(i).getInReplyToStatusId()); if (breakTimeline && isFirst) args.put("has_more_tweets_down", 1); DataFramework.getInstance().getDB().insert("tweets_user", null, args); nextId++; if (isFirst) isFirst = false; } } } catch (SQLException e) { e.printStackTrace(); } DataFramework.getInstance().close(); } } return response; } catch (TwitterException twitterException) { twitterException.printStackTrace(); ErrorResponse errorResponse = new ErrorResponse(); errorResponse.setError(twitterException, twitterException.getMessage()); return errorResponse; } catch (Exception exception) { exception.printStackTrace(); ErrorResponse errorResponse = new ErrorResponse(); errorResponse.setError(exception, exception.getMessage()); return errorResponse; } }