List of usage examples for twitter4j User getBiggerProfileImageURL
String getBiggerProfileImageURL();
From source file:com.rowland.hashtrace.utility.Utility.java
License:Apache License
public static Tweet createTweet(Status status) { User user = status.getUser(); long tweet_id = status.getId(); String tweet_text = status.getText(); Date tweet_text_date = status.getCreatedAt(); int tweet_retweet_count = status.getRetweetCount(); int tweet_favourite_count = status.getFavoriteCount(); int tweet_mentions_count = status.getUserMentionEntities().length; String user_name = user.getScreenName(); String user_image_url = user.getBiggerProfileImageURL(); String user_cover_url = user.getProfileBackgroundImageURL(); String user_location = user.getLocation(); String user_description = user.getDescription(); Tweet tweet = new Tweet(tweet_id, tweet_text, tweet_text_date, tweet_retweet_count, tweet_favourite_count, tweet_mentions_count, user_name, user_image_url, user_location, user_description, user_cover_url); return tweet; }
From source file:com.soomla.profile.social.twitter.SoomlaTwitter.java
License:Apache License
private UserProfile createUserProfile(User user, boolean withExtraFields) { String fullName = user.getName(); String firstName = ""; String lastName = ""; if (!TextUtils.isEmpty(fullName)) { String[] splitName = fullName.split(" "); if (splitName.length > 0) { firstName = splitName[0];//from w ww. j a v a2 s . co m if (splitName.length > 1) { lastName = splitName[1]; } } } Map<String, Object> extraDict = Collections.<String, Object>emptyMap(); if (withExtraFields) { extraDict = new HashMap<String, Object>(); // TwitterException will throws when Twitter service or network is unavailable, or the user has not authorized try { extraDict.put("access_token", twitter.getOAuthAccessToken().getToken()); } catch (TwitterException twitterExc) { SoomlaUtils.LogError(TAG, twitterExc.getErrorMessage()); } } //Twitter does not supply email access: https://dev.twitter.com/faq#26 UserProfile result = new UserProfile(RefProvider, String.valueOf(user.getId()), user.getScreenName(), "", firstName, lastName, extraDict); // No gender information on Twitter: // https://twittercommunity.com/t/how-to-find-male-female-accounts-in-following-list/7367 result.setGender(""); // No birthday on Twitter: // https://twittercommunity.com/t/how-can-i-get-email-of-user-if-i-use-api/7019/16 result.setBirthday(""); result.setLanguage(user.getLang()); result.setLocation(user.getLocation()); result.setAvatarLink(user.getBiggerProfileImageURL()); return result; }
From source file:net.codestory.http.filters.twitter.TwitterAuthenticator.java
License:Apache License
@Override public User authenticate(String oauthToken, String oauthVerifier) { Twitter twitter = twitterFactory.getInstance(); try {//from w ww .j av a 2s. c o m AccessToken accessToken = twitter.getOAuthAccessToken(oauthRequestByToken.remove(oauthToken), oauthVerifier); twitter4j.User user = twitter.users().showUser(accessToken.getUserId()); return new User(accessToken.getUserId(), accessToken.getScreenName(), accessToken.getToken(), accessToken.getTokenSecret(), user.getBiggerProfileImageURL()); } catch (TwitterException e) { throw new AuthenticationException(e); } }
From source file:net.lacolaco.smileessence.view.dialog.UserDetailDialogFragment.java
License:Open Source License
private void initUserData(User user, final Account account) { textViewName.setText(user.getName()); textViewScreenName.setText(user.getScreenName()); if (TextUtils.isEmpty(user.getLocation())) { textViewLocate.setVisibility(View.GONE); } else {/*from w w w .j a va 2 s . com*/ textViewLocate.setText(user.getLocation()); } if (TextUtils.isEmpty(user.getURL())) { textViewURL.setVisibility(View.GONE); } else { textViewURL.setText(user.getURL()); } textViewTweetCount.setText(String.valueOf(user.getStatusesCount())); textViewFriendCount.setText(String.valueOf(user.getFriendsCount())); textViewFollowerCount.setText(String.valueOf(user.getFollowersCount())); textViewFavoriteCount.setText(String.valueOf(user.getFavouritesCount())); textViewProtected.setVisibility(user.isProtected() ? View.VISIBLE : View.GONE); String htmlDescription = getHtmlDescription(user.getDescription()); textViewDescription.setText(Html.fromHtml(htmlDescription)); textViewDescription.setMovementMethod(LinkMovementMethod.getInstance()); ImageCache.getInstance().setImageToView(user.getBiggerProfileImageURL(), imageViewIcon); ImageCache.getInstance().setImageToView(user.getProfileBannerURL(), imageViewHeader); MainActivity activity = (MainActivity) getActivity(); final StatusListAdapter adapter = new StatusListAdapter(activity); listViewTimeline.setAdapter(adapter); listViewTimeline.setOnRefreshListener(this); activity.setListAdapter(ADAPTER_INDEX, adapter); executeUserTimelineTask(user, account, adapter); updateRelationship(activity, user.getId()); }
From source file:net.lacolaco.smileessence.viewmodel.UserViewModel.java
License:Open Source License
public UserViewModel(User user) { id = user.getId();/*from w w w .j av a2 s .co m*/ screenName = user.getScreenName(); name = user.getName(); description = user.getDescription(); location = user.getLocation(); url = user.getURL(); iconURL = user.getBiggerProfileImageURL(); bannerURL = user.getProfileBannerURL(); statusesCount = user.getStatusesCount(); friendsCount = user.getFriendsCount(); followersCount = user.getFollowersCount(); favoritesCount = user.getFavouritesCount(); isProtected = user.isProtected(); isVerified = user.isVerified(); }
From source file:org.kawalpemilukada.login.callbackTwit.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w ww . j ava 2s. com*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Twitter twitter = (Twitter) request.getSession().getAttribute("twitter"); RequestToken requestToken = (RequestToken) request.getSession().getAttribute("requestToken"); String verifier = request.getParameter("oauth_verifier"); String rurl = request.getParameter("rurl"); try { twitter.getOAuthAccessToken(requestToken, verifier); request.getSession().removeAttribute("requestToken"); } catch (TwitterException e) { } request.getSession().setAttribute("twitter", twitter); String errorMsg = "Data Anda belum terverifikasi."; Dashboard dashboard = CommonServices.getDashboard(CommonServices.setParentId("2015", "0")); Dashboard dashboard2014 = CommonServices.getDashboard(CommonServices.setParentId("2014", "0")); request.getSession().removeAttribute("tahun"); UserData user = null; try { User u = twitter.showUser(twitter.getId()); user = ofy().load().type(UserData.class).id("twit" + CommonServices.getVal(twitter.getId())).now(); if (user == null) { user = new UserData("twit" + CommonServices.getVal(twitter.getId())); user.imgurl = u.getBiggerProfileImageURLHttps().replace("http://", "https://"); user.nama = CommonServices.getVal(u.getName()); user.link = "https://twitter.com/" + CommonServices.getVal(twitter.getScreenName()); user.email = ""; user.type = "twit"; user.userlevel = 100; user.terverifikasi = "Y"; ofy().save().entity(user).now(); dashboard.users = CommonServices.getuserSize() + ""; ofy().save().entity(dashboard).now(); dashboard2014.users = dashboard.users + ""; ofy().save().entity(dashboard2014).now(); } else { user.lastlogin = CommonServices.JakartaTime(); user.type = "twit"; user.imgurl = u.getBiggerProfileImageURL().replace("http://", "https://"); if (user.type.equalsIgnoreCase("twit") && user.nama.equalsIgnoreCase(CommonServices.getVal(u.getName()))) { if (user.terverifikasi.equalsIgnoreCase("Y")) { errorMsg = ""; } } else { user.nama = CommonServices.getVal(u.getName()); user.terverifikasi = "N"; } ofy().save().entity(user).now(); } Gson gson = new Gson(); request.getSession().setAttribute("UserData", JSONValue.parse(gson.toJson(user))); } catch (Exception e) { errorMsg = "callbackTwit [processRequest] ==> " + e.toString(); } response.setContentType("text/html;charset=UTF-8"); Gson gson = new Gson(); try (PrintWriter out = response.getWriter()) { /* TODO output your page here. You may use following sample code. */ out.println("<!DOCTYPE html>"); out.println("<html>"); out.println("<head>"); out.println("<title>Kawal Pemilu Kepala Daerah</title>"); out.println("<script src=\"/bower_components/jquery/dist/jquery.min.js\"></script>"); out.println("<script src=\"/dist/js/vendor.js\"></script>"); out.println("</head>"); out.println("<body>Sedang Login..."); out.println("<script>"); out.println("if (!jQuery.browser.mobile) {"); out.println("try{window.opener.inviteCallback(" + gson.toJson(user) + "," + gson.toJson(dashboard) + ",'" + errorMsg + "');}catch(e){window.location='/'}"); out.println("self.close();"); out.println("}else{window.location='/#" + rurl + "'}"); out.println("</script>"); out.println("</body>"); out.println("</html>"); } }
From source file:org.sociotech.communitymashup.source.twitter.TwitterSourceService.java
License:Open Source License
/** * Looks up the person for this twitter user in the given dataSet and * returns it. If it does not already exist, the person will be created and * returned.//from ww w. ja va 2 s.c om * * @param user * @return */ private Person createPersonFromTwitterUser(User user) { if (user == null) { return null; } Person person = getPersonForTwitterUser(user); String personIdent = createPersonIdentForTwitterUser(user); if (person == null) { // not previously created person = factory.createPerson(); // set name person.setName(user.getName()); // and add the person to the data set person = (Person) this.add(person, personIdent); } if (person == null) { // person could not be created return null; } // tag person person.metaTag(TwitterTags.TWITTER); // add web account String screenName = user.getScreenName(); if (screenName != null && !screenName.equals("")) { // TODO check for existing web account WebAccount webAccount = factory.createWebAccount(); webAccount.setUsername(screenName); webAccount.setCreated(user.getCreatedAt()); webAccount = (WebAccount) this.add(webAccount, screenName); if (webAccount != null) { webAccount.metaTag(TwitterTags.TWITTER); person.extend(webAccount); } } // add location String twitterLocation = user.getLocation(); if (twitterLocation != null && !twitterLocation.equals("")) { Location location = factory.createLocation(); location.setStringValue(twitterLocation); location = (Location) this.add(location, "uloc_" + user.getId()); if (location != null) { location.metaTag(TwitterTags.TWITTER); person.extend(location); } } // add website String twitterWebsite = user.getURL(); if (twitterWebsite != null) { WebSite website = factory.createWebSite(); website.setAdress(twitterWebsite.toString()); website = (WebSite) this.add(website); if (website != null) { website.metaTag(TwitterTags.TWITTER); person.extend(website); } } // add profile image String profileImageUrl = user.getBiggerProfileImageURL(); // add original res version if available if (screenName != null && source.isPropertyTrueElseDefault(TwitterProperties.LOAD_HIGHER_RES_PROFILE_IMAGE_PROPERTY, TwitterProperties.LOAD_HIGHER_RES_PROFILE_IMAGE_DEFAULT)) { if (user.getOriginalProfileImageURL() != null) { profileImageUrl = user.getOriginalProfileImageURL(); } } if (profileImageUrl != null) { // create image Image profileImage = person.attachImage(profileImageUrl); profileImage.tag(TwitterTags.TWITTER); profileImage.tag(TwitterTags.PROFILE_IMAGE); } // add latest status of user Status status = user.getStatus(); if (status != null && source.isPropertyTrue(TwitterProperties.ADD_STATUS_OF_PEOPLE_PROPERTY)) { createContentFromTweet(person, status); } return person; }
From source file:org.soluvas.buzz.twitter.TwitterUser.java
License:Apache License
/** * Clones attributes from Twitter4j's {@link User}. * @param src//from w w w. j a v a 2s . c o m */ public TwitterUser(User src, int revId, DateTime fetchTime) { super(); this.revId = revId; this.fetchTime = fetchTime; id = src.getId(); name = src.getName(); screenName = src.getScreenName(); location = src.getLocation(); description = src.getDescription(); contributorsEnabled = src.isContributorsEnabled(); profileImageUrl = src.getProfileImageURL(); biggerProfileImageUrl = src.getBiggerProfileImageURL(); miniProfileImageUrl = src.getMiniProfileImageURL(); originalProfileImageUrl = src.getOriginalProfileImageURL(); profileImageUrlHttps = src.getProfileImageURLHttps(); biggerProfileImageUrlHttps = src.getBiggerProfileImageURLHttps(); miniProfileImageUrlHttps = src.getMiniProfileImageURLHttps(); originalProfileImageUrlHttps = src.getOriginalProfileImageURLHttps(); url = src.getURL(); protectedState = src.isProtected(); followersCount = src.getFollowersCount(); status = src.getStatus(); profileBackgroundColor = src.getProfileBackgroundColor(); profileTextColor = src.getProfileTextColor(); profileLinkColor = src.getProfileLinkColor(); profileSidebarFillColor = src.getProfileSidebarFillColor(); profileSidebarBorderColor = src.getProfileSidebarBorderColor(); profileUseBackgroundImage = src.isProfileUseBackgroundImage(); showAllInlineMedia = src.isShowAllInlineMedia(); friendsCount = src.getFriendsCount(); createdAt = new DateTime(src.getCreatedAt()); favouritesCount = src.getFavouritesCount(); utcOffset = src.getUtcOffset(); timeZone = src.getTimeZone(); profileBackgroundImageUrl = src.getProfileBackgroundImageURL(); profileBackgroundImageUrlHttps = src.getProfileBackgroundImageUrlHttps(); profileBannerUrl = src.getProfileBannerURL(); profileBannerRetinaUrl = src.getProfileBannerRetinaURL(); profileBannerIpadUrl = src.getProfileBannerIPadURL(); profileBannerIpadRetinaUrl = src.getProfileBannerIPadRetinaURL(); profileBannerMobileUrl = src.getProfileBannerMobileURL(); profileBannerMobileRetinaUrl = src.getProfileBannerMobileRetinaURL(); profileBackgroundTiled = src.isProfileBackgroundTiled(); lang = src.getLang(); statusesCount = src.getStatusesCount(); geoEnabled = src.isGeoEnabled(); verified = src.isVerified(); translator = src.isTranslator(); listedCount = src.getListedCount(); followRequestSent = src.isFollowRequestSent(); }
From source file:org.tweetalib.android.model.TwitterDirectMessage.java
License:Apache License
public TwitterDirectMessage(DirectMessage message, User otherUser) { mId = message.getId();/*from w ww. j av a 2s . co m*/ mText = message.getText(); mStatusFullMarkup = TwitterUtil.getStatusMarkup(mText, message.getMediaEntities(), message.getURLEntities()); mTextSpanned = URLSpanNoUnderline .stripUnderlines(Html.fromHtml(mStatusFullMarkup.replace("\n", "<br/>") + " ")); mCreatedAt = message.getCreatedAt(); mOtherUserId = otherUser.getId(); mRecipientUserId = message.getRecipientId(); mOtherUserScreenName = otherUser.getScreenName(); mOtherUserName = otherUser.getName(); mOtherUserProfileImageOriginalUrl = otherUser.getOriginalProfileImageURL(); mOtherUserProfileImageMiniUrl = otherUser.getMiniProfileImageURL(); mOtherUserProfileImageNormalUrl = otherUser.getProfileImageURL(); mOtherUserProfileImageBiggerUrl = otherUser.getBiggerProfileImageURL(); TwitterUser sender = new TwitterUser(message.getSender()); mSenderProfileImageOriginalUrl = sender.getProfileImageUrlOriginal(); mSenderProfileImageMiniUrl = sender.getProfileImageUrlMini(); mSenderProfileImageNormalUrl = sender.getProfileImageUrlNormal(); mSenderProfileImageBiggerUrl = sender.getProfileImageUrlBigger(); mMessageType = mRecipientUserId == mOtherUserId ? MessageType.SENT : MessageType.RECEIVED; }