Example usage for twitter4j User getScreenName

List of usage examples for twitter4j User getScreenName

Introduction

In this page you can find the example usage for twitter4j User getScreenName.

Prototype

String getScreenName();

Source Link

Document

Returns the screen name of the user

Usage

From source file:kerguelenpetrel.UnfriendSomeoneServlet.java

License:Apache License

public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    User unfriend = null;
    Random r = new Random();

    resp.setContentType("text/plain; charset=UTF-8");
    try {//from  ww w  . j av  a 2 s.c o m
        //Get the Twitter object
        Twitter twit = TwitterFactory.getSingleton();

        //Find a friend of a follower to bother
        long[] followerIDs = twit.getFollowersIDs(twit.getId(), cursor).getIDs();
        if (followerIDs.length == 0) {
            resp.getWriter().println("No friends to unfollow");
            return;
        }
        unfriend = twit.showUser(followerIDs[r.nextInt(followerIDs.length)]);
        twit.destroyFriendship(unfriend.getId());
        resp.getWriter().println("Successfully unfollowed @" + unfriend.getScreenName());
        resp.getWriter().println("\n");
    } catch (TwitterException e) {
        resp.getWriter().println("Problem with Twitter \n");
        e.printStackTrace(resp.getWriter());
    } catch (Exception e) {
        resp.getWriter().println("Problem! \n");
        e.printStackTrace(resp.getWriter());
    }
}

From source file:kr.debop4j.search.twitter.Twitters.java

License:Apache License

protected static String getUserAsString(User user) {
    StringBuilder sb = new StringBuilder();
    return sb.append("id=").append(user.getId()).append(",").append("name=").append(user.getName()).append(",")
            .append("screenName=").append(user.getScreenName()).append(",").append("description=")
            .append(user.getDescription()).toString();
}

From source file:Logic.mongoC.java

public void IngresarUsuario(String name) {

    String[] buscarUs = new String[1];
    buscarUs[0] = name;/* ww  w  .j ava 2  s.c  om*/
    try {
        ResponseList<twitter4j.User> use = twitter.lookupUsers(buscarUs);
        twitter4j.User u = use.get(0);
        System.out.println(u.getStatus());
        usuario nuevoS = new usuario();
        nuevoS.setId(Long.toString(u.getId()));
        nuevoS.setNombre(u.getName());
        nuevoS.setLocation(u.getLocation());
        nuevoS.setNumFol(u.getFollowersCount());
        nuevoS.setNumeroDeT(u.getStatusesCount());
        List<Status> twitts = twitter.getUserTimeline(u.getId(), new Paging(1, 200));
        ArrayList<twitt> timeL = new ArrayList();
        for (Status s : twitts) {
            twitt tw = new twitt();
            tw.setTexto(s.getText());
            tw.setRetwett(s.getRetweetCount());
            //tw.setFecha((java.util.Date) s.getCreatedAt());
            tw.setFav(s.getFavoriteCount());
            tw.setCreador(s.getUser().getScreenName());
            UserMentionEntity[] userMentionEntities = s.getUserMentionEntities();
            ArrayList<String> inter = new ArrayList();
            for (UserMentionEntity uh : userMentionEntities) {
                inter.add(uh.getScreenName());
            }
            tw.setPersonas(inter);
            timeL.add(tw);
        }
        nuevoS.setTimeline(timeL);
        final String fIns = gson.toJson(nuevoS);

        Document dt;
        dt = new Document("ScreenName", u.getScreenName());
        dt.append("todo", fIns);
        conect();
        coll.insertOne(dt);
        JOptionPane.showMessageDialog(null, "Usuario Ingresado");
    }

    catch (TwitterException ex) {
        System.out.println("No se pudo conectar el usuario deseado");
    }

}

From source file:main.TwitterController.java

License:Open Source License

public String printUser(User u) {
    return u.getName() + " (" + u.getScreenName() + ")";
}

From source file:net.chrissearle.spring.twitter.spring.Twitter4jFollowService.java

License:Apache License

private List<String> populateUsernameList(IDs ids) throws TwitterException {
    List<String> usernames = new ArrayList<String>();

    for (int id : ids.getIDs()) {
        User user = twitter.showUser(id);

        if (logger.isLoggable(Level.FINE)) {
            logger.fine(new StringBuilder().append("Saw user: ").append(user.getName()).append(" ")
                    .append(user.getScreenName()).toString());
        }//  w w  w.j a v a2 s .c o m

        usernames.add(user.getScreenName());
    }

    return usernames;
}

From source file:net.firejack.platform.web.security.twitter.BaseTwitterAuthenticationProcessor.java

License:Apache License

protected Map<String, String> getTwitterUserInformation(Twitter twitterService) throws TwitterException {
    Map<String, String> userInfo = new HashMap<String, String>();
    long id = twitterService.getId();
    userInfo.put(TW_USER_ID, String.valueOf(id));

    String screenName = twitterService.getScreenName();
    userInfo.put(TW_SCREEN_NAME, screenName);

    twitter4j.User user = twitterService.showUser(id);
    userInfo.put(TW_US_SCREEN_NAME, user.getScreenName());
    userInfo.put(TW_US_NAME, user.getName());
    userInfo.put(TW_US_PROFILE_IMAGE_URL, user.getProfileImageURL());

    return userInfo;
}

From source file:net.lacolaco.smileessence.view.dialog.UserDetailDialogFragment.java

License:Open Source License

@Override
public void onClick(final View v) {
    final MainActivity activity = (MainActivity) getActivity();
    final Account account = activity.getCurrentAccount();
    TwitterUtils.tryGetUser(account, getUserID(), new TwitterUtils.UserCallback() {
        @Override// ww w  .  ja  v a2  s  .  c om
        public void success(final User user) {
            switch (v.getId()) {
            case R.id.imageview_user_detail_menu: {
                openUserMenu(activity, user);
                break;
            }
            case R.id.imageview_user_detail_icon: {
                openUrl(user.getBiggerProfileImageURLHttps());
                break;
            }
            case R.id.textview_user_detail_screenname: {
                openUrl(TwitterUtils.getUserHomeURL(user.getScreenName()));
                break;
            }
            case R.id.textview_user_detail_tweet_count: {
                openUrl(TwitterUtils.getUserHomeURL(user.getScreenName()));
                break;
            }
            case R.id.textview_user_detail_friend_count: {
                openUrl(String.format("%s/following", TwitterUtils.getUserHomeURL(user.getScreenName())));
                break;
            }
            case R.id.textview_user_detail_follower_count: {
                openUrl(String.format("%s/followers", TwitterUtils.getUserHomeURL(user.getScreenName())));
                break;
            }
            case R.id.textview_user_detail_favorite_count: {
                openUrl(String.format("%s/favorites", TwitterUtils.getUserHomeURL(user.getScreenName())));
                break;
            }
            case R.id.button_user_detail_follow: {
                ConfirmDialogFragment.show(activity, getString(R.string.dialog_confirm_commands),
                        new Runnable() {
                            @Override
                            public void run() {
                                toggleFollowing(user, account, activity);
                            }
                        });
                break;
            }
            }
        }

        @Override
        public void error() {
            dismiss();
        }
    });
}

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 {// ww w . j  av a 2s.co  m
        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.view.dialog.UserMenuDialogFragment.java

License:Open Source License

public boolean addBottomCommands(Activity activity, User user, ArrayList<Command> commands) {
    return commands.add(new CommandSearchOnTwitter(activity, user.getScreenName()));
}

From source file:net.lacolaco.smileessence.viewmodel.EventViewModel.java

License:Open Source License

public EventViewModel(EnumEvent event, User source, Status status) {
    this.event = event;
    this.createdAt = new Date();
    this.sourceUserID = source.getId();
    this.sourceScreenName = source.getScreenName();
    this.sourceName = source.getName();
    this.iconURL = source.getProfileImageURL();

    if (status != null) {
        if (event == EnumEvent.RETWEETED) {
            this.targetStatusID = status.getRetweetedStatus().getId();
            this.targetText = status.getRetweetedStatus().getText();
        } else {/*from ww w  . ja va  2 s. co  m*/
            this.targetStatusID = status.getId();
            this.targetText = status.getText();
        }
    } else {
        this.targetStatusID = -1L;
        this.targetText = "";
    }
}