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]; 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; }
/** * Called whenever an exception has occurred while running a Twitter4J asynchronous action * * @param e The exception which was thrown * @param twitterMethod The method which failed */ @Override public void onException(TwitterException e, TwitterMethod twitterMethod) { SoomlaUtils.LogDebug(TAG, "General fail " + e.getMessage()); failListener(preformingAction, e.getMessage()); }