Example usage for twitter4j User getName

List of usage examples for twitter4j User getName

Introduction

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

Prototype

String getName();

Source Link

Document

Returns the name of the user

Usage

From source file:fr.istic.taa.jaxrs.TweetEndpoint.java

License:Apache License

@GET
@Path("/followers/{id}")
@Produces(MediaType.TEXT_PLAIN)// w w w.ja va 2  s.  c o m
public String getFollowers(@PathParam("id") String id) {

    String result = "";
    long cursor = -1;
    PagableResponseList<User> list_l;
    try {
        do {
            list_l = link.getFollowersList(id, cursor);
            for (User user_l : list_l) {
                result += user_l.getName() + "\n";
            }
        } while ((cursor = list_l.getNextCursor()) != 0);

    } catch (TwitterException e) {
        logger.error(e.getMessage(), e);
    }

    return result;

}

From source file:info.maslowis.twitterripper.util.Util.java

License:Open Source License

/**
 * Returns a representation the user as string
 *
 * @return a representation the user as string in format <em>User{id=, name='', screenName='', location='', description=''}</em>
 *///from   www  . j  ava 2 s . c  o  m
public static String toString(final User user) {
    return "User{id=" + user.getId() + ", name='" + user.getName() + "', screenName='" + user.getScreenName()
            + "', location='" + user.getLocation() + "', description='" + user.getDescription() + "'}";
}

From source file:it.baywaylabs.jumpersumo.twitter.TwitterUtility.java

License:Open Source License

/**
 *
 * Twitter utility for extract twitter username from id.
 *
 * @param id Twitter User id.// w ww  . ja  va2  s. c  om
 * @param twitter Twitter4j instance.
 * @return Twitter User Name or blank string if is not find.
 */
public String getNameUser(Long id, Twitter twitter) {
    if (twitter != null) {
        User user = null;
        try {
            user = twitter.showUser(id);
        } catch (TwitterException e) {
            e.printStackTrace();
        }
        return user.getName();
    }
    return "";
}

From source file:Jimbo.Cheerlights.TweetListener.java

License:Open Source License

private static String userText(User u) {
    return u.getName() + " (@" + u.getScreenName() + ")";
}

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;//from   w w  w. j a v a2  s  .  co  m
    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());
        }/*from w  w w  . j a  v  a 2  s .co  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

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.jav a2s.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());
}