Package twitter4j

Examples of twitter4j.User


    avroSchema.setFields(fields);
    return avroSchema;
  }

  private Record extractRecord(String idPrefix, Schema avroSchema, Status status) {
    User user = status.getUser();
    Record doc = new Record(avroSchema);

    doc.put("id", idPrefix + status.getId());
    doc.put("created_at", formatterTo.format(status.getCreatedAt()));
    doc.put("retweet_count", status.getRetweetCount());
    doc.put("retweeted", status.isRetweet());
    doc.put("in_reply_to_user_id", status.getInReplyToUserId());
    doc.put("in_reply_to_status_id", status.getInReplyToStatusId());

    addString(doc, "source", status.getSource());
    addString(doc, "text", status.getText());

    MediaEntity[] mediaEntities = status.getMediaEntities();
    if (mediaEntities.length > 0) {
      addString(doc, "media_url_https", mediaEntities[0].getMediaURLHttps());
      addString(doc, "expanded_url", mediaEntities[0].getExpandedURL());
    }

    doc.put("user_friends_count", user.getFriendsCount());
    doc.put("user_statuses_count", user.getStatusesCount());
    doc.put("user_followers_count", user.getFollowersCount());
    addString(doc, "user_location", user.getLocation());
    addString(doc, "user_description", user.getDescription());
    addString(doc, "user_screen_name", user.getScreenName());
    addString(doc, "user_name", user.getName());
    return doc;
  }
View Full Code Here


        query.setRpp(100);
        QueryResult result = twitter.search(query);
        System.out.println("hits:" + result.getResultsPerPage());
        System.out.println(result.getMaxId() + " :" + result.getPage());
        for (Tweet tweet : result.getTweets()) {           
            User user = twitter.showUser(tweet.getFromUser());
            System.out.println(user.getLocation());
            if (user.isGeoEnabled()) {
                GeoLocation geo = user.getStatus() != null ? user.getStatus().getGeoLocation() : null;
                System.out.println(geo + ":" + tweet.getLocation() + ":" + tweet.getFromUser() + ":" + tweet.getText());
            }
        }

    }
View Full Code Here

      TwitterFactory tf = new TwitterFactory(cb.build());

      this.twitter = tf.getInstance();

      User user = this.twitter.verifyCredentials();

      logger.info("Connected to twitter account " + user.getName());
    }
    catch(Exception e)
    {
      logger.warning(e.getMessage());
    }
View Full Code Here

    System.out.println("Verify user credentials.");
    // Returns an HTTP 200 OK response code and a representation of the
    // requesting user if authentication was successful; returns a 401
    // status code and an error message if not. Use this method to test if
    // supplied user credentials are valid.
    User cUser = TWITTER_CLIENT.verifyCredentials();
    if (cUser != null) {
      System.out.printf("Name       : %s\n", cUser.getName());
      System.out.printf("Location   : %s\n", cUser.getLocation());
      System.out.printf("ScreenName : %s\n", cUser.getScreenName());
      System.out.printf("StatusText : %s\n", cUser.getStatusText());
      System.out.printf("TimeZone   : %s\n", cUser.getTimeZone());
    } else {
      System.err.println("Invalid credentials !!!");
    }
    System.out.println("\nTwitter client version.");
    System.out.printf("Client URL     : %s\n", TWITTER_CLIENT.getClientURL());
View Full Code Here

    System.out.println("Verify user credentials.");
    // Returns an HTTP 200 OK response code and a representation of the
    // requesting user if authentication was successful; returns a 401
    // status code and an error message if not. Use this method to test if
    // supplied user credentials are valid.
    User cUser = TWITTER_CLIENT.verifyCredentials();
    if (cUser != null) {
      System.out.printf("Name       : %s\n", cUser.getName());
      System.out.printf("Location   : %s\n", cUser.getLocation());
      System.out.printf("ScreenName : %s\n", cUser.getScreenName());
      System.out.printf("StatusText : %s\n", cUser.getStatusText());
      System.out.printf("TimeZone   : %s\n", cUser.getTimeZone());
    } else {
      System.err.println("Invalid credentials !!!");
    }
    System.out.println("\nTwitter client version.");
    System.out.printf("Client URL     : %s\n", TWITTER_CLIENT.getClientURL());
View Full Code Here

          theMap.put("htags", Arrays.asList(hashTags.get(0)));
        }

        long retweetCount = status.getRetweetCount();
        theMap.put("retweet_count", retweetCount);
        User user = status.getUser();
        if (user != null) {
          theMap.put("follower_count", user.getFollowersCount());
          theMap.put("friends_count", user.getFriendsCount());
          theMap.put("lang", user.getLang());
          theMap.put("utc_offset", user.getUtcOffset())// resolution in seconds, -1 if not available?
          theMap.put("statuses_count", user.getStatusesCount());
        }

        return new MapBasedInputRow(status.getCreatedAt().getTime(), dimensions, theMap);
      }
View Full Code Here

            int size = list.length();
            PagableResponseList<User> users =
                    new PagableResponseListImpl<User>(size, json, res);
            for (int i = 0; i < size; i++) {
                JSONObject userJson = list.getJSONObject(i);
                User user = new UserJSONImpl(userJson);
                if (conf.isJSONStoreEnabled()) {
                    DataObjectFactoryUtil.registerJSONObject(user, userJson);
                }
                users.add(user);
            }
View Full Code Here

            int size = list.length();
            ResponseList<User> users =
                    new ResponseListImpl<User>(size, res);
            for (int i = 0; i < size; i++) {
                JSONObject json = list.getJSONObject(i);
                User user = new UserJSONImpl(json);
                users.add(user);
                if (conf.isJSONStoreEnabled()) {
                    DataObjectFactoryUtil.registerJSONObject(user, json);
                }
            }
View Full Code Here

    public TwitterFrame(Twitter twitter) throws TwitterException, MalformedURLException {
        initComponents();
        setTitle("Twitter + Java - Geeky Theory");
        this.twitter=twitter;
       
        User usuario=twitter.showUser(twitter.getId());
        URL urlIMG=new URL(usuario.getProfileImageURL());
        ImageIcon img=new ImageIcon(urlIMG);
        jLabel1.setIcon(img);
        actualizar();
        setVisible(true);
    }
View Full Code Here

        // set path because the cookie should be sent for / and /slide* and /login*
        cookie.setPath("/");
        response.addCookie(cookie);

        // get current infos
        User twitterUser = twitterSearch.getTwitterUser();

        // get current saved searches and update with current twitter infos
        JUser tmpUser = uSearch.findById(token.getUserId());
        if (tmpUser == null) {
            tmpUser = uSearch.findByScreenName(twitterUser.getScreenName());
            if (tmpUser == null)
                tmpUser = new JUser(twitterUser.getScreenName());
        }

        tmpUser.updateFieldsBy(twitterUser);
        // now set email entered on form one page before twitter redirect
        tmpUser.setEmail(email);
        tmpUser.setTwitterToken(token.getToken());
        tmpUser.setTwitterTokenSecret(token.getTokenSecret());
        tmpUser.setLastVisit(new Date());

        // save user into user index
        uSearch.save(tmpUser, false);

        // save user into session
        setUser(tmpUser);

        logger.info("[stats] user login:" + twitterUser.getScreenName() + " " + tmpUser.getScreenName());
        return cookie;
    }
View Full Code Here

TOP

Related Classes of twitter4j.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.