Example usage for twitter4j User getStatus

List of usage examples for twitter4j User getStatus

Introduction

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

Prototype

Status getStatus();

Source Link

Document

Returns the current status of the user
This can be null if the instance if from Status.getUser().

Usage

From source file:de.jetwick.data.JUser.java

License:Apache License

/**
 * This method refreshes the properties of this user by the specified
 * Twitter4j user/*www  .ja v a 2 s  .  com*/
 * @param user
 */
public Status updateFieldsBy(User user) {
    twitterId = user.getId();
    setProtected(user.isProtected());
    setTwitterCreatedAt(user.getCreatedAt());
    setDescription(user.getDescription());
    addLanguage(user.getLang());
    setLocation(TwitterSearch.toStandardLocation(user.getLocation()));
    setRealName(user.getName());

    // user.getFollowersCount();
    // user.getFriendsCount();
    // user.getTimeZone()

    if (user.getProfileImageURL() != null)
        setProfileImageUrl(user.getProfileImageURL().toString());

    if (user.getURL() != null)
        setWebUrl(user.getURL().toString());

    setFollowersCount(user.getFollowersCount());
    setFriendsCount(user.getFriendsCount());
    return user.getStatus();
}

From source file:demo.UserInfo.java

License:Apache License

public static void main(String[] args) throws IOException, TwitterException {
    //?//from   www . ja  va 2  s  .c  om
    Configuration configuration = new ConfigurationBuilder().setOAuthConsumerKey(CONSUMER_KEY)
            .setOAuthConsumerSecret(CONSUMER_SECRET).setOAuthAccessToken(ACCESS_TOKEN)
            .setOAuthAccessTokenSecret(ACCESS_TOKEN_SECRET).build();
    Twitter tw = new TwitterFactory(configuration).getInstance();
    String screenName = "";

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    System.out.print("????ScreenName???????!! ex)masason : ");
    screenName = br.readLine();
    //String screenName = "masason";//masason
    try {
        //?&
        User user = tw.showUser(screenName);
        System.out.println("???");
        System.out.println("User ID : " + user.getId());
        System.out.println("ScreenName : " + user.getScreenName());
        System.out.println("User's Name : " + user.getName());
        System.out.println("Number of Followers : " + user.getFollowersCount());
        System.out.println("Number of Friends : " + user.getFriendsCount());
        System.out.println("Language : " + user.getLang());
        //?
        Status status = user.getStatus();
        System.out.println("???");
        System.out.println("User Created : " + status.getCreatedAt());
        System.out.println("Status ID : " + status.getId());
        System.out.println(status.getSource());
        System.out.println("Tweet" + status.getText());

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Logic.mongoC.java

public void IngresarUsuario(String name) {

    String[] buscarUs = new String[1];
    buscarUs[0] = name;/*  w w  w  .  j  a  v a  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:org.sociotech.communitymashup.source.twitter.TwitterSourceService.java

License:Open Source License

/**
 * Creates the user of the mashup and adds him to the dataset
 *///  w  ww.  j  a v  a 2 s .  c om
private void addMe() {

    // get Twitter user
    User user = null;
    try {
        user = twitterAPI.verifyCredentials();
    } catch (Exception e) {
        log("Could not get user from twiter (" + e.getMessage() + ")", LogService.LOG_ERROR);
        return;
    }

    Person me = createPersonFromTwitterUser(user);
    me.metaTag(TwitterTags.PROVIDED_PROFILE);

    accountOwnerUser = user;

    // add status
    Status twitterStatus = user.getStatus();

    createContentFromTweet(me, twitterStatus);
}

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./* w  w w.  ja  v a  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  www  .j av  a2 s . c  om*/
 */
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.xmlsh.twitter.util.TwitterWriter.java

License:BSD License

private void write(String localName, User user) throws XMLStreamException {
    startElement("user");
    attribute("created-at", user.getCreatedAt());
    attribute("description", user.getDescription());
    attribute("favorites-count", user.getFavouritesCount());
    user.getFollowersCount();//w ww .  j av  a  2s  .  com
    user.getFriendsCount();
    attribute("id", sanitizeID(user.getId()));
    attribute("lang", user.getLang());
    user.getListedCount();

    attribute("name", sanitizeUser(user.getName()));
    user.getProfileBackgroundColor();
    user.getProfileBackgroundImageUrl();
    user.getProfileBackgroundImageUrlHttps();
    user.getProfileImageURL();
    user.getProfileImageUrlHttps();
    user.getProfileLinkColor();
    user.getProfileSidebarBorderColor();
    user.getProfileTextColor();
    user.getRateLimitStatus();
    attribute("screen-name", sanitizeUser(user.getScreenName()));

    user.getStatusesCount();
    user.getTimeZone();
    user.getURL();
    user.getUtcOffset();
    write("location", user.getLocation());
    write("user-status", user.getStatus());
    endElement();

}

From source file:peoplesearch.SearchTwitterUsers.java

public void SearchTwitterUsers() {
    int page = 1;
    int numberofpages = 0;
    Date TwitterAccCreatedAt = new Date();
    String TwitterAccDescr = " ";
    int TwitterFollowersCount = 0;
    int TwitterFriendsCount = 0;
    boolean TwitterGeoEnabled = false;
    String TwitterLocation = " ";
    String TwiterAccScrName = " ";
    long TwitterID = 0L;

    try {//www.  j a v a2 s .c o  m

        Twitter twitter = new TwitterFactory().getInstance();
        ResponseList<User> users;
        List<Person> people = null;
        GraphManager mgr = EmbeddedGraphManager.getInstance();
        mgr.init(new File("/usr/local/Cellar/neo4j/2.1.7/libexec/data/forlang1.db"));

        mgr.addPerson(new PersonImpl("wgaura"));
        mgr.addPerson(new PersonImpl("Derek Mizak"));
        mgr.addPerson(new PersonImpl("Swiderek"));
        mgr.addPerson(new PersonImpl("Microsoft"));
        mgr.addPerson(new PersonImpl("BBC"));
        mgr.addPerson(new PersonImpl("RTE"));
        mgr.addPerson(new PersonImpl("CNBC"));
        mgr.addPerson(new PersonImpl("Poland"));
        mgr.addPerson(new PersonImpl("Ireland"));
        mgr.addPerson(new PersonImpl("Ergo"));

        people = mgr.listPeople();

        for (Person person : people) {
            do {
                TwitterLimitWait tlw = new TwitterLimitWait();
                tlw.CheckLimit();

                users = twitter.searchUsers(person.getName(), page);
                numberofpages = users.size() / 20;

                for (User user : users) {
                    if (user.getStatus() != null) {

                        TwitterAccCreatedAt = user.getCreatedAt();
                        if (!user.getDescription().isEmpty()) {
                            TwitterAccDescr = user.getDescription();
                        }
                        //if (user.getFollowersCount()>0) {TwitterFollowersCount=user.getFavouritesCount();}
                        //if  (user.getFriendsCount()>0) {TwitterFriendsCount=user.getFriendsCount();}
                        TwitterFollowersCount = user.getFollowersCount();
                        TwitterFriendsCount = user.getFriendsCount();
                        TwitterGeoEnabled = user.isGeoEnabled();
                        if (!user.getLocation().isEmpty()) {
                            TwitterLocation = user.getLocation();
                        }
                        TwiterAccScrName = user.getScreenName();
                        TwitterID = user.getId();

                        System.out.println("@" + user.getScreenName() + " - " + TwitterFollowersCount + " _ "
                                + TwitterFriendsCount);

                        //mgr.addTwitterAccount(new TwitterAccountImpl(TwitterAccCreatedAt,TwitterAccDescr,TwitterFollowersCount,TwitterFriendsCount,TwitterGeoEnabled,TwitterLocation,TwiterAccScrName,TwitterID));
                        mgr.linkPersonToTwitterAccount(person,
                                new TwitterAccountImpl(TwitterAccCreatedAt, TwitterAccDescr,
                                        TwitterFollowersCount, TwitterFriendsCount, TwitterGeoEnabled,
                                        TwitterLocation, TwiterAccScrName, TwitterID));

                        TwitterAccDescr = " ";
                        TwitterLocation = " ";
                        TwitterFollowersCount = 0;
                        TwitterFriendsCount = 0;

                        //numberofusers++;

                    } else {
                        // the user is protected
                        System.out.println("@" + user.getScreenName());
                    }
                }

                page++;
                //System.out.println(page);
            } while (users.size() != 0 && page < numberofpages);
        }
    } catch (Exception ex) {
        System.out.println(ex.getMessage());
    }
}

From source file:twitter4j.examples.suggestedusers.GetMemberSuggestions.java

License:Apache License

/**
 * Usage: java twitter4j.examples.suggestedusers.GetMemberSuggestions [slug]
 *
 * @param args message//from  w  w  w.  j a  v a 2  s . c o  m
 */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.suggestedusers.GetMemberSuggestions [slug]");
        System.exit(-1);
    }
    System.out.println("Showing suggested users in " + args[0] + " category.");
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        ResponseList<User> users = twitter.getMemberSuggestions(args[0]);
        for (User user : users) {
            if (user.getStatus() != null) {
                System.out.println("@" + user.getScreenName() + " - " + user.getStatus().getText());
            } else {
                // the user is protected
                System.out.println("@" + user.getScreenName());
            }
        }
        System.out.println("done.");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get suggested users: " + te.getMessage());
        System.exit(-1);
    }
}

From source file:twitter4j.examples.suggestedusers.GetUserSuggestions.java

License:Apache License

/**
 * Usage: java twitter4j.examples.suggestedusers.GetUserSuggestions [slug]
 *
 * @param args message//from  w w  w.  j a  v  a  2 s  . co m
 */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.suggestedusers.GetUserSuggestions [slug]");
        System.exit(-1);
    }
    System.out.println("Showing suggested users in " + args[0] + " category.");
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        ResponseList<User> users = twitter.getUserSuggestions(args[0]);
        for (User user : users) {
            if (user.getStatus() != null) {
                System.out.println("@" + user.getScreenName() + " - " + user.getStatus().getText());
            } else {
                // the user is protected
                System.out.println("@" + user.getScreenName());
            }
        }
        System.out.println("done.");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get suggested users: " + te.getMessage());
        System.exit(-1);
    }
}