Example usage for twitter4j URLEntity getExpandedURL

List of usage examples for twitter4j URLEntity getExpandedURL

Introduction

In this page you can find the example usage for twitter4j URLEntity getExpandedURL.

Prototype

String getExpandedURL();

Source Link

Document

Returns the expanded URL if mentioned URL is shorten.

Usage

From source file:org.xmlsh.twitter.util.TwitterWriter.java

License:BSD License

private void write(URLEntity u) throws XMLStreamException {
    attribute("display-url", u.getDisplayURL());
    attribute("end", u.getEnd());
    attribute("expanded-url", u.getExpandedURL().toString());
    attribute("start", u.getStart());
    attribute("url", u.getURL().toString());

}

From source file:uk.ac.susx.tag.method51.twitter.User.java

License:Apache License

public User(twitter4j.User user) {
    id = user.getId();//from  w  ww .j a v a2 s  . c o m
    createdAt = user.getCreatedAt();
    description = user.getDescription();
    lang = user.getLang();
    geoEnabled = user.isGeoEnabled();
    location = user.getLocation();
    timeZone = user.getTimeZone();
    utcOffset = user.getUtcOffset();
    name = user.getName();
    screenName = user.getScreenName();
    url = user.getURL();
    statusesCount = user.getStatusesCount();
    followersCount = user.getFollowersCount();

    URLEntity[] urlEntities = user.getDescriptionURLEntities();
    entities = "";
    for (URLEntity entity : urlEntities) {
        entities += entity.getExpandedURL() + " ";
    }

    favouritesCount = user.getFavouritesCount();
    friendsCount = user.getFriendsCount();
    listedCount = user.getListedCount();
    profileBackgroundColor = user.getProfileBackgroundColor();
    profileBackgroundImageUrl = user.getProfileBackgroundImageURL();
    profileBackgroundImageUrlHttps = user.getProfileBackgroundImageUrlHttps();
    profileBannerUrl = user.getProfileBannerURL();
    profileImageUrl = user.getProfileImageURL();
    profileImageUrlHttps = user.getProfileImageURLHttps();
}

From source file:wise.TwitterUtils.java

public ArrayList<CheckinObject> dataList(String cityCode, String selectedDate, String maxTweetParam,
        String topTweetParam) throws IOException, JSONException, ParseException {
    ArrayList<CheckinObject> checkinList = new ArrayList<>();

    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true).setOAuthConsumerKey(Constants.CONSUMER_KEY)
            .setOAuthConsumerSecret(Constants.CONSUMER_SECRET).setOAuthAccessToken(Constants.TOKEN)
            .setOAuthAccessTokenSecret(Constants.TOKEN_SECRET);

    Integer maxTweet = Integer.parseInt(maxTweetParam);
    Integer topTweet = Integer.parseInt(topTweetParam);

    TwitterFactory tf = new TwitterFactory(cb.build());
    Twitter twitter = tf.getInstance();/* w w  w  . j a v a2  s . c  om*/

    DateFormat format = new SimpleDateFormat("MM/dd/yyyy", Locale.ENGLISH);

    Date startDate = format.parse(selectedDate);

    Calendar c = Calendar.getInstance();
    c.setTime(startDate);
    c.add(Calendar.DATE, 1);
    Date endDate = c.getTime();

    Query query = SetQueryString(cityCode, startDate, endDate);

    QueryResult result = null;
    try {
        while (query != null && checkinList.size() <= maxTweet) {
            result = twitter.search(query);
            if (result != null) {
                for (Status status : result.getTweets()) {

                    for (URLEntity urlEntity : status.getURLEntities()) {
                        String urlCheckinId = urlEntity.getExpandedURL()
                                .substring(urlEntity.getExpandedURL().lastIndexOf("/") + 1);
                        GeoLocation geo = status.getGeoLocation();

                        CheckinObject checkin = new CheckinObject();
                        checkin.CheckinId = urlCheckinId;
                        checkin.Count = 1;//status.getRetweetCount() + status.getFavoriteCount() + 1;
                        checkin.Latitude = geo.getLatitude();
                        checkin.Longitude = geo.getLongitude();

                        if (!checkin.containsSameCoordinates(checkinList, checkin.Latitude,
                                checkin.Longitude)) {
                            checkinList.add(checkin);
                        } else {
                            int indexOfCheckinId = checkin.getIndexByCoordinates(checkinList, checkin.Latitude,
                                    checkin.Longitude);
                            checkinList.get(indexOfCheckinId).setCheckinCount(checkin.Count);
                            checkinList.get(indexOfCheckinId).setReplacementCheckinId(checkin.CheckinId);
                        }
                    }
                }

                query = result.nextQuery();
            } else {
                query = null;
            }
        }

    } catch (TwitterException e) {
    }

    Collections.sort(checkinList, new CountComparator());

    if (checkinList.size() > topTweet) {
        checkinList.subList(topTweet, checkinList.size()).clear(); // get top x
    }

    FourSquareCheckin fsq = new FourSquareCheckin();

    for (CheckinObject checkin : checkinList) {
        fsq = getVenueInfo(checkin);
        checkin.LocationName = fsq.VenueName;
        checkin.Image = fsq.VenueImage;
    }

    return checkinList;
}