Example usage for twitter4j User getLocation

List of usage examples for twitter4j User getLocation

Introduction

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

Prototype

String getLocation();

Source Link

Document

Returns the location of the user

Usage

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>
 *//* w  w  w . j a  v a2  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:io.druid.examples.twitter.TwitterSpritzerFirehoseFactory.java

License:Apache License

@Override
public Firehose connect(InputRowParser parser) throws IOException {
    final ConnectionLifeCycleListener connectionLifeCycleListener = new ConnectionLifeCycleListener() {
        @Override/*from  w  w w. j  a  v  a 2s.c  o m*/
        public void onConnect() {
            log.info("Connected_to_Twitter");
        }

        @Override
        public void onDisconnect() {
            log.info("Disconnect_from_Twitter");
        }

        /**
         * called before thread gets cleaned up
         */
        @Override
        public void onCleanUp() {
            log.info("Cleanup_twitter_stream");
        }
    }; // ConnectionLifeCycleListener

    final TwitterStream twitterStream;
    final StatusListener statusListener;
    final int QUEUE_SIZE = 2000;
    /** This queue is used to move twitter events from the twitter4j thread to the druid ingest thread.   */
    final BlockingQueue<Status> queue = new ArrayBlockingQueue<Status>(QUEUE_SIZE);
    final long startMsec = System.currentTimeMillis();

    //
    //   set up Twitter Spritzer
    //
    twitterStream = new TwitterStreamFactory().getInstance();
    twitterStream.addConnectionLifeCycleListener(connectionLifeCycleListener);
    statusListener = new StatusListener() { // This is what really gets called to deliver stuff from twitter4j
        @Override
        public void onStatus(Status status) {
            // time to stop?
            if (Thread.currentThread().isInterrupted()) {
                throw new RuntimeException("Interrupted, time to stop");
            }
            try {
                boolean success = queue.offer(status, 15L, TimeUnit.SECONDS);
                if (!success) {
                    log.warn("queue too slow!");
                }
            } catch (InterruptedException e) {
                throw new RuntimeException("InterruptedException", e);
            }
        }

        @Override
        public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
            //log.info("Got a status deletion notice id:" + statusDeletionNotice.getStatusId());
        }

        @Override
        public void onTrackLimitationNotice(int numberOfLimitedStatuses) {
            // This notice will be sent each time a limited stream becomes unlimited.
            // If this number is high and or rapidly increasing, it is an indication that your predicate is too broad, and you should consider a predicate with higher selectivity.
            log.warn("Got track limitation notice:" + numberOfLimitedStatuses);
        }

        @Override
        public void onScrubGeo(long userId, long upToStatusId) {
            //log.info("Got scrub_geo event userId:" + userId + " upToStatusId:" + upToStatusId);
        }

        @Override
        public void onException(Exception ex) {
            ex.printStackTrace();
        }

        @Override
        public void onStallWarning(StallWarning warning) {
            System.out.println("Got stall warning:" + warning);
        }
    };

    twitterStream.addListener(statusListener);
    twitterStream.sample(); // creates a generic StatusStream
    log.info("returned from sample()");

    return new Firehose() {

        private final Runnable doNothingRunnable = new Runnable() {
            public void run() {
            }
        };

        private long rowCount = 0L;
        private boolean waitIfmax = (getMaxEventCount() < 0L);
        private final Map<String, Object> theMap = new TreeMap<>();
        // DIY json parsing // private final ObjectMapper omapper = new ObjectMapper();

        private boolean maxTimeReached() {
            if (getMaxRunMinutes() <= 0) {
                return false;
            } else {
                return (System.currentTimeMillis() - startMsec) / 60000L >= getMaxRunMinutes();
            }
        }

        private boolean maxCountReached() {
            return getMaxEventCount() >= 0 && rowCount >= getMaxEventCount();
        }

        @Override
        public boolean hasMore() {
            if (maxCountReached() || maxTimeReached()) {
                return waitIfmax;
            } else {
                return true;
            }
        }

        @Override
        public InputRow nextRow() {
            // Interrupted to stop?
            if (Thread.currentThread().isInterrupted()) {
                throw new RuntimeException("Interrupted, time to stop");
            }

            // all done?
            if (maxCountReached() || maxTimeReached()) {
                if (waitIfmax) {
                    // sleep a long time instead of terminating
                    try {
                        log.info("reached limit, sleeping a long time...");
                        sleep(2000000000L);
                    } catch (InterruptedException e) {
                        throw new RuntimeException("InterruptedException", e);
                    }
                } else {
                    // allow this event through, and the next hasMore() call will be false
                }
            }
            if (++rowCount % 1000 == 0) {
                log.info("nextRow() has returned %,d InputRows", rowCount);
            }

            Status status;
            try {
                status = queue.take();
            } catch (InterruptedException e) {
                throw new RuntimeException("InterruptedException", e);
            }

            theMap.clear();

            HashtagEntity[] hts = status.getHashtagEntities();
            String text = status.getText();
            theMap.put("text", (null == text) ? "" : text);
            theMap.put("htags", (hts.length > 0)
                    ? Lists.transform(Arrays.asList(hts), new Function<HashtagEntity, String>() {
                        @Nullable
                        @Override
                        public String apply(HashtagEntity input) {
                            return input.getText();
                        }
                    })
                    : ImmutableList.<String>of());

            long[] lcontrobutors = status.getContributors();
            List<String> contributors = new ArrayList<>();
            for (long contrib : lcontrobutors) {
                contributors.add(String.format("%d", contrib));
            }
            theMap.put("contributors", contributors);

            GeoLocation geoLocation = status.getGeoLocation();
            if (null != geoLocation) {
                double lat = status.getGeoLocation().getLatitude();
                double lon = status.getGeoLocation().getLongitude();
                theMap.put("lat", lat);
                theMap.put("lon", lon);
            } else {
                theMap.put("lat", null);
                theMap.put("lon", null);
            }

            if (status.getSource() != null) {
                Matcher m = sourcePattern.matcher(status.getSource());
                theMap.put("source", m.find() ? m.group(1) : status.getSource());
            }

            theMap.put("retweet", status.isRetweet());

            if (status.isRetweet()) {
                Status original = status.getRetweetedStatus();
                theMap.put("retweet_count", original.getRetweetCount());

                User originator = original.getUser();
                theMap.put("originator_screen_name", originator != null ? originator.getScreenName() : "");
                theMap.put("originator_follower_count",
                        originator != null ? originator.getFollowersCount() : "");
                theMap.put("originator_friends_count", originator != null ? originator.getFriendsCount() : "");
                theMap.put("originator_verified", originator != null ? originator.isVerified() : "");
            }

            User user = status.getUser();
            final boolean hasUser = (null != user);
            theMap.put("follower_count", hasUser ? user.getFollowersCount() : 0);
            theMap.put("friends_count", hasUser ? user.getFriendsCount() : 0);
            theMap.put("lang", hasUser ? user.getLang() : "");
            theMap.put("utc_offset", hasUser ? user.getUtcOffset() : -1); // resolution in seconds, -1 if not available?
            theMap.put("statuses_count", hasUser ? user.getStatusesCount() : 0);
            theMap.put("user_id", hasUser ? String.format("%d", user.getId()) : "");
            theMap.put("screen_name", hasUser ? user.getScreenName() : "");
            theMap.put("location", hasUser ? user.getLocation() : "");
            theMap.put("verified", hasUser ? user.isVerified() : "");

            theMap.put("ts", status.getCreatedAt().getTime());

            List<String> dimensions = Lists.newArrayList(theMap.keySet());

            return new MapBasedInputRow(status.getCreatedAt().getTime(), dimensions, theMap);
        }

        @Override
        public Runnable commit() {
            // ephemera in, ephemera out.
            return doNothingRunnable; // reuse the same object each time
        }

        @Override
        public void close() throws IOException {
            log.info("CLOSE twitterstream");
            twitterStream.shutdown(); // invokes twitterStream.cleanUp()
        }
    };
}

From source file:Logic.mongoC.java

public void IngresarUsuario(String name) {

    String[] buscarUs = new String[1];
    buscarUs[0] = name;/*from  www.ja  v  a 2 s .com*/
    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: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 {/* w ww  .  j a v  a  2s .  c  o  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.viewmodel.UserViewModel.java

License:Open Source License

public UserViewModel(User user) {
    id = user.getId();//from   w  ww  . j a  v  a  2 s.co  m
    screenName = user.getScreenName();
    name = user.getName();
    description = user.getDescription();
    location = user.getLocation();
    url = user.getURL();
    iconURL = user.getBiggerProfileImageURL();
    bannerURL = user.getProfileBannerURL();
    statusesCount = user.getStatusesCount();
    friendsCount = user.getFriendsCount();
    followersCount = user.getFollowersCount();
    favoritesCount = user.getFavouritesCount();
    isProtected = user.isProtected();
    isVerified = user.isVerified();
}

From source file:org.apache.druid.examples.twitter.TwitterSpritzerFirehoseFactory.java

License:Apache License

@Override
public Firehose connect(InputRowParser parser, File temporaryDirectory) {
    final ConnectionLifeCycleListener connectionLifeCycleListener = new ConnectionLifeCycleListener() {
        @Override/*from w  w w  .  j  a  v  a  2s  .  com*/
        public void onConnect() {
            log.info("Connected_to_Twitter");
        }

        @Override
        public void onDisconnect() {
            log.info("Disconnect_from_Twitter");
        }

        /**
         * called before thread gets cleaned up
         */
        @Override
        public void onCleanUp() {
            log.info("Cleanup_twitter_stream");
        }
    }; // ConnectionLifeCycleListener

    final TwitterStream twitterStream;
    final StatusListener statusListener;
    final int QUEUE_SIZE = 2000;
    /** This queue is used to move twitter events from the twitter4j thread to the druid ingest thread.   */
    final BlockingQueue<Status> queue = new ArrayBlockingQueue<Status>(QUEUE_SIZE);
    final long startMsec = System.currentTimeMillis();

    //
    //   set up Twitter Spritzer
    //
    twitterStream = new TwitterStreamFactory().getInstance();
    twitterStream.addConnectionLifeCycleListener(connectionLifeCycleListener);
    statusListener = new StatusListener() { // This is what really gets called to deliver stuff from twitter4j
        @Override
        public void onStatus(Status status) {
            // time to stop?
            if (Thread.currentThread().isInterrupted()) {
                throw new RuntimeException("Interrupted, time to stop");
            }
            try {
                boolean success = queue.offer(status, 15L, TimeUnit.SECONDS);
                if (!success) {
                    log.warn("queue too slow!");
                }
            } catch (InterruptedException e) {
                throw new RuntimeException("InterruptedException", e);
            }
        }

        @Override
        public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
            //log.info("Got a status deletion notice id:" + statusDeletionNotice.getStatusId());
        }

        @Override
        public void onTrackLimitationNotice(int numberOfLimitedStatuses) {
            // This notice will be sent each time a limited stream becomes unlimited.
            // If this number is high and or rapidly increasing, it is an indication that your predicate is too broad, and you should consider a predicate with higher selectivity.
            log.warn("Got track limitation notice:" + numberOfLimitedStatuses);
        }

        @Override
        public void onScrubGeo(long userId, long upToStatusId) {
            //log.info("Got scrub_geo event userId:" + userId + " upToStatusId:" + upToStatusId);
        }

        @Override
        public void onException(Exception ex) {
            log.error(ex, "Got exception");
        }

        @Override
        public void onStallWarning(StallWarning warning) {
            log.warn("Got stall warning: %s", warning);
        }
    };

    twitterStream.addListener(statusListener);
    twitterStream.sample(); // creates a generic StatusStream
    log.info("returned from sample()");

    return new Firehose() {

        private final Runnable doNothingRunnable = new Runnable() {
            @Override
            public void run() {
            }
        };

        private long rowCount = 0L;
        private boolean waitIfmax = (getMaxEventCount() < 0L);
        private final Map<String, Object> theMap = new TreeMap<>();
        // DIY json parsing // private final ObjectMapper omapper = new ObjectMapper();

        private boolean maxTimeReached() {
            if (getMaxRunMinutes() <= 0) {
                return false;
            } else {
                return (System.currentTimeMillis() - startMsec) / 60000L >= getMaxRunMinutes();
            }
        }

        private boolean maxCountReached() {
            return getMaxEventCount() >= 0 && rowCount >= getMaxEventCount();
        }

        @Override
        public boolean hasMore() {
            if (maxCountReached() || maxTimeReached()) {
                return waitIfmax;
            } else {
                return true;
            }
        }

        @Nullable
        @Override
        public InputRow nextRow() {
            // Interrupted to stop?
            if (Thread.currentThread().isInterrupted()) {
                throw new RuntimeException("Interrupted, time to stop");
            }

            // all done?
            if (maxCountReached() || maxTimeReached()) {
                if (waitIfmax) {
                    // sleep a long time instead of terminating
                    try {
                        log.info("reached limit, sleeping a long time...");
                        Thread.sleep(2000000000L);
                    } catch (InterruptedException e) {
                        throw new RuntimeException("InterruptedException", e);
                    }
                } else {
                    // allow this event through, and the next hasMore() call will be false
                }
            }
            if (++rowCount % 1000 == 0) {
                log.info("nextRow() has returned %,d InputRows", rowCount);
            }

            Status status;
            try {
                status = queue.take();
            } catch (InterruptedException e) {
                throw new RuntimeException("InterruptedException", e);
            }

            theMap.clear();

            HashtagEntity[] hts = status.getHashtagEntities();
            String text = status.getText();
            theMap.put("text", (null == text) ? "" : text);
            theMap.put("htags", (hts.length > 0)
                    ? Lists.transform(Arrays.asList(hts), new Function<HashtagEntity, String>() {
                        @Nullable
                        @Override
                        public String apply(HashtagEntity input) {
                            return input.getText();
                        }
                    })
                    : ImmutableList.<String>of());

            long[] lcontrobutors = status.getContributors();
            List<String> contributors = new ArrayList<>();
            for (long contrib : lcontrobutors) {
                contributors.add(StringUtils.format("%d", contrib));
            }
            theMap.put("contributors", contributors);

            GeoLocation geoLocation = status.getGeoLocation();
            if (null != geoLocation) {
                double lat = status.getGeoLocation().getLatitude();
                double lon = status.getGeoLocation().getLongitude();
                theMap.put("lat", lat);
                theMap.put("lon", lon);
            } else {
                theMap.put("lat", null);
                theMap.put("lon", null);
            }

            if (status.getSource() != null) {
                Matcher m = sourcePattern.matcher(status.getSource());
                theMap.put("source", m.find() ? m.group(1) : status.getSource());
            }

            theMap.put("retweet", status.isRetweet());

            if (status.isRetweet()) {
                Status original = status.getRetweetedStatus();
                theMap.put("retweet_count", original.getRetweetCount());

                User originator = original.getUser();
                theMap.put("originator_screen_name", originator != null ? originator.getScreenName() : "");
                theMap.put("originator_follower_count",
                        originator != null ? originator.getFollowersCount() : "");
                theMap.put("originator_friends_count", originator != null ? originator.getFriendsCount() : "");
                theMap.put("originator_verified", originator != null ? originator.isVerified() : "");
            }

            User user = status.getUser();
            final boolean hasUser = (null != user);
            theMap.put("follower_count", hasUser ? user.getFollowersCount() : 0);
            theMap.put("friends_count", hasUser ? user.getFriendsCount() : 0);
            theMap.put("lang", hasUser ? user.getLang() : "");
            theMap.put("utc_offset", hasUser ? user.getUtcOffset() : -1); // resolution in seconds, -1 if not available?
            theMap.put("statuses_count", hasUser ? user.getStatusesCount() : 0);
            theMap.put("user_id", hasUser ? StringUtils.format("%d", user.getId()) : "");
            theMap.put("screen_name", hasUser ? user.getScreenName() : "");
            theMap.put("location", hasUser ? user.getLocation() : "");
            theMap.put("verified", hasUser ? user.isVerified() : "");

            theMap.put("ts", status.getCreatedAt().getTime());

            List<String> dimensions = Lists.newArrayList(theMap.keySet());

            return new MapBasedInputRow(status.getCreatedAt().getTime(), dimensions, theMap);
        }

        @Override
        public Runnable commit() {
            // ephemera in, ephemera out.
            return doNothingRunnable; // reuse the same object each time
        }

        @Override
        public void close() {
            log.info("CLOSE twitterstream");
            twitterStream.shutdown(); // invokes twitterStream.cleanUp()
        }
    };
}

From source file:org.apache.flume.sink.solr.morphline.TwitterSource.java

License:Apache License

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());
    }/* www.j  a va 2s .  c om*/

    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;
}

From source file:org.bireme.interop.toJson.Twitter2Json.java

License:Open Source License

private JSONObject getDocument(final Status status) {
    assert status != null;

    final JSONObject obj = new JSONObject();
    final GeoLocation geo = status.getGeoLocation();
    final Place place = status.getPlace();
    final User user = status.getUser();

    obj.put("createdAt", status.getCreatedAt()).put("id", status.getId()).put("lang", status.getLang());
    if (geo != null) {
        obj.put("location_latitude", geo.getLatitude()).put("location_longitude", geo.getLongitude());
    }//w  w w.ja  v a2  s .com
    if (place != null) {
        obj.put("place_country", place.getCountry()).put("place_fullName", place.getFullName())
                .put("place_id", place.getId()).put("place_name", place.getName())
                .put("place_type", place.getPlaceType()).put("place_streetAddress", place.getStreetAddress())
                .put("place_url", place.getURL());
    }
    obj.put("source", status.getSource()).put("text", status.getText());
    if (user != null) {
        obj.put("user_description", user.getDescription()).put("user_id", user.getId())
                .put("user_lang", user.getLang()).put("user_location", user.getLocation())
                .put("user_name", user.getName()).put("user_url", user.getURL());
    }
    obj.put("isTruncated", status.isTruncated()).put("isRetweet", status.isRetweet());

    return obj;
}

From source file:org.botlibre.sense.twitter.Twitter.java

License:Open Source License

public boolean checkFriendship(long friendId, boolean welcomeOnly) throws TwitterException {
    long[] lookup = new long[1];
    lookup[0] = friendId;//from   ww w .ja  v  a2 s.  c  o  m
    ResponseList<User> users = getConnection().lookupUsers(lookup);
    User friend = users.get(0);
    if (friend.getScreenName().equals(getUserName())) {
        return false;
    }
    if (!getAutoFollowKeywords().isEmpty()) {
        StringWriter writer = new StringWriter();
        writer.write(friend.getScreenName().toLowerCase());
        writer.write(" ");
        writer.write(friend.getDescription().toLowerCase());
        writer.write(" ");
        writer.write(friend.getLocation().toLowerCase());
        writer.write(" ");
        writer.write(friend.getLang().toLowerCase());
        writer.write(" ");
        writer.write(friend.getName().toLowerCase());
        boolean match = false;
        for (String text : getAutoFollowKeywords()) {
            List<String> keywords = new TextStream(text.toLowerCase()).allWords();
            if (new TextStream(writer.toString()).allWords().containsAll(keywords)) {
                match = true;
                break;
            }
        }
        if (!match) {
            log("Autofollow skipping friend, does not match keywords", Level.FINE, friend.getScreenName());
            return false;
        }
    }
    Network memory = getBot().memory().newMemory();
    Vertex speaker = memory.createSpeaker(friend.getScreenName());
    speaker.setPinned(true);
    // Only try to follow a user once.
    if (!speaker.hasRelationship(Primitive.FOLLOWED)) {
        speaker.addRelationship(Primitive.FOLLOWED, memory.createTimestamp());
        memory.save();
        if (!welcomeOnly && getAutoFollow()) {
            log("Adding autofollow friend.", Level.INFO, friend.getScreenName());
            getConnection().createFriendship(friendId);
            Utils.sleep(1000);
        }
        if (!getWelcomeMessage().isEmpty()) {
            log("Sending welcome message.", Level.INFO, friend.getScreenName());
            sendMessage(getWelcomeMessage(), friend.getScreenName());
            Utils.sleep(1000);
        }
        if (welcomeOnly) {
            return false;
        }
        return true;
    }
    log("Autofollow skipping friend, already followed once", Level.FINE, friend.getScreenName());
    return false;
}

From source file:org.encuestame.social.api.templates.TwitterAPITemplate.java

License:Apache License

@Override
public SocialUserProfile getProfile() throws Exception {
    final SocialUserProfile profile = new SocialUserProfile();
    User user = this.getUser();
    profile.setId(String.valueOf(user.getId()));
    profile.setCreatedAt(user.getCreatedAt());
    profile.setProfileUrl("http://www.twitter.com/" + user.getScreenName());
    profile.setName(user.getName());//from w  w w .j av a  2  s  . c o m
    profile.setScreenName(user.getScreenName());
    profile.setUsername(user.getScreenName());
    profile.setProfileImageUrl(user.getProfileImageURL().toString());
    profile.setDescription(user.getDescription());
    profile.setCreatedAt(user.getCreatedAt());
    profile.setLocation(user.getLocation());
    return profile;
}