List of usage examples for twitter4j User getScreenName
String getScreenName();
From source file:com.redhat.ipaas.example.TweetToContactMapper.java
License:Apache License
@Override public void process(Exchange exchange) throws Exception { Message in = exchange.getIn();/*www . j a va 2 s . c o m*/ Status status = exchange.getIn().getBody(Status.class); User user = status.getUser(); String name = user.getName(); String screenName = user.getScreenName(); Contact contact = new Contact(); contact.setLastName(name); contact.setTwitterScreenName__c(screenName); in.setBody(contact); }
From source file:com.revolucion.secretwit.ui.SignupPane.java
License:Open Source License
private void init() { labelInfo = new MultilineLabel( "SecreTwit uses OAuth authentication for safe access to your Twitter account."); numberAuthorize = new NumberRenderer(1); labelAuthorize = new JLabel("Please first authorize this application on Twitter.com"); buttonAuthorize = new JButton("Sign in to Twitter in browser"); buttonAuthorize.addActionListener(new ActionListener() { @Override//w w w. j a v a 2 s. c o m public void actionPerformed(ActionEvent e) { String authorizationUrl = TwitterClient.getInstance().getAuthorizationUrl(); logger.info("Authorization url: {}", authorizationUrl); SystemUtils.openWebSite(authorizationUrl); /* int option = JOptionPane.showOptionDialog(SignupPane.this, "Please use following link to authorize this application.", "Authorization", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[] { "Open in browser", "Copy link" }, "Open in browser"); if (option == 0) { // Open url in default browser SystemUtils.openWebSite(authorizationUrl); } else if (option == 1) { // Copy url to clipboard StringSelection contents = new StringSelection(authorizationUrl); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(contents, contents); } */ fieldPin.setEnabled(true); } }); numberPin = new NumberRenderer(2); labelPin = new JLabel("Then enter the PIN provided to you by Twitter.com"); fieldPin = new JTextField(10); fieldPin.setEnabled(false); fieldPin.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { buttonSignIn.setEnabled(e.getLength() != 0); } @Override public void insertUpdate(DocumentEvent e) { buttonSignIn.setEnabled(e.getLength() != 0); } @Override public void changedUpdate(DocumentEvent e) { buttonSignIn.setEnabled(e.getLength() != 0); } }); buttonSignIn = new JButton("Sign in"); buttonSignIn.setEnabled(false); buttonSignIn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String pin = fieldPin.getText(); if (pin != null && !pin.isEmpty()) { try { User authorizedUser = TwitterClient.getInstance().authorize(pin); if (authorizedUser != null) { HeaderPane.getInstance().setPlace("@home"); HeaderPane.getInstance().setUserStatus(authorizedUser.getScreenName(), true); ViewManager.getInstance().showTimelineView(); TimelinePane.getInstance().reload(); MessagePane.getInstance().setEnabled(true); } } catch (TwitterException te) { logger.error("Authorization error. {} - {}", te.getExceptionCode(), te.getMessage()); JOptionPane.showMessageDialog(SignupPane.this, "<html><b>Authorization failed.</b><br>" + te.getMessage(), "Authorization Error", JOptionPane.ERROR_MESSAGE); } } } }); buttonCancel = new JButton("Cancel"); buttonCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { HeaderPane.getInstance().setPlace("@public"); HeaderPane.getInstance().setUserStatus(null, false); ViewManager.getInstance().showTimelineView(); } }); add(labelInfo, "span, growx, wrap"); add(numberAuthorize, "spany 2"); add(labelAuthorize, "wrap"); add(buttonAuthorize, "growx, wrap"); add(numberPin, "spany 2"); add(labelPin, "wrap"); add(fieldPin, "split 2"); add(buttonSignIn, "growx, wrap"); add(buttonCancel, "span, tag cancel"); }
From source file:com.ridhofkr.hanacaraka.connector.twitter.TwitterApp.java
License:Apache License
public void processToken(String callbackUrl) { mProgressDlg.setMessage("Finalizing ..."); mProgressDlg.show();/*from w ww .j a v a2s. co m*/ final String verifier = getVerifier(callbackUrl); new Thread() { @Override public void run() { int what = 1; try { mHttpOauthprovider.retrieveAccessToken(mHttpOauthConsumer, verifier); mAccessToken = new AccessToken(mHttpOauthConsumer.getToken(), mHttpOauthConsumer.getTokenSecret()); configureToken(); User user = mTwitter.verifyCredentials(); mSession.storeAccessToken(mAccessToken, user.getScreenName()); what = 0; } catch (Exception e) { e.printStackTrace(); } mHandler.sendMessage(mHandler.obtainMessage(what, 2, 0)); } }.start(); }
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 www . j a v a2s.c o 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:com.tuncaysenturk.jira.plugins.compatibility.servlet.TwitterLoginServlet.java
private void twitterCallback(HttpServletRequest req, HttpServletResponse resp, Map<String, Object> context) { if (null == req.getParameter("denied") && null != req.getParameter("oauth_verifier")) { String verifier = req.getParameter("oauth_verifier").toString(); PropertySet propSet = ComponentManager.getComponent(PropertiesManager.class).getPropertySet(); propSet.setString("accessTokenVerifier", verifier); Twitter twitter = new TwitterFactory().getInstance(); twitter.setOAuthConsumer(propSet.getString("consumerKey"), propSet.getString("consumerSecret")); RequestToken requestToken = new RequestToken(propSet.getString("requestToken"), propSet.getString("requestTokenSecret")); propSet.remove("requestToken"); propSet.remove("requestTokenSecret"); try {/*from www . j a v a2s .c o m*/ AccessToken accessToken = twitter.getOAuthAccessToken(requestToken, verifier); propSet.setString("accessToken", accessToken.getToken()); propSet.setString("accessTokenSecret", accessToken.getTokenSecret()); User user = twitter.verifyCredentials(); logger.info(JTPConstants.LOG_PRE + "User :" + user.getScreenName() + " logged in successfully"); restartListener(req, resp, context); } catch (TwitterException e) { logger.error(JTPConstants.LOG_PRE + "Error while streaming", e); ExceptionMessagesUtil.addExceptionMessage("Error while streaming : ", e); } } else { logger.warn(JTPConstants.LOG_PRE + "User denied Twitter authorization, plugin will not work properly"); ExceptionMessagesUtil .addExceptionMessage("User denied Twitter authorization, plugin will not work properly"); } }
From source file:com.tuncaysenturk.jira.plugins.jtp.twitter.JiraTwitterUserStreamListener.java
public void onFollow(User source, User followedUser) { logger.info(JTPConstants.LOG_PRE + "just logging, onFollow source:@" + source.getScreenName() + " target:@" + followedUser.getScreenName()); if (null != followers) followers.add(followedUser.getId()); }
From source file:com.tuncaysenturk.jira.plugins.jtp.twitter.JiraTwitterUserStreamListener.java
public void onUserListMemberAddition(User addedMember, User listOwner, UserList list) { logger.info(JTPConstants.LOG_PRE + "just logging, onUserListMemberAddition added member:@" + addedMember.getScreenName() + " listOwner:@" + listOwner.getScreenName() + " list:" + list.getName());/*from w ww . j a va 2 s . c o m*/ }
From source file:com.tuncaysenturk.jira.plugins.jtp.twitter.JiraTwitterUserStreamListener.java
public void onUserListMemberDeletion(User deletedMember, User listOwner, UserList list) { logger.info(JTPConstants.LOG_PRE + "just logging, onUserListMemberDeleted deleted member:@" + deletedMember.getScreenName() + " listOwner:@" + listOwner.getScreenName() + " list:" + list.getName());//from www .ja va 2 s. c om }
From source file:com.tuncaysenturk.jira.plugins.jtp.twitter.JiraTwitterUserStreamListener.java
public void onUserListSubscription(User subscriber, User listOwner, UserList list) { logger.info(JTPConstants.LOG_PRE + "just logging, onUserListSubscribed subscriber:@" + subscriber.getScreenName() + " listOwner:@" + listOwner.getScreenName() + " list:" + list.getName());// ww w. j a va 2 s . com }