Example usage for twitter4j Status getCreatedAt

List of usage examples for twitter4j Status getCreatedAt

Introduction

In this page you can find the example usage for twitter4j Status getCreatedAt.

Prototype

Date getCreatedAt();

Source Link

Document

Return the created_at

Usage

From source file:com.klinker.android.twitter.data.sq_lite.MentionsDataSource.java

License:Apache License

public synchronized void createTweet(Status status, int account) {
    ContentValues values = new ContentValues();
    String originalName = "";
    long id = status.getId();
    long time = status.getCreatedAt().getTime();

    String[] html = TweetLinkUtils.getLinksInStatus(status);
    String text = html[0];/*from  w  ww.ja v  a2s. c  o m*/
    String media = html[1];
    String otherUrl = html[2];
    String hashtags = html[3];
    String users = html[4];

    values.put(MentionsSQLiteHelper.COLUMN_ACCOUNT, account);
    values.put(MentionsSQLiteHelper.COLUMN_TEXT, text);
    values.put(MentionsSQLiteHelper.COLUMN_TWEET_ID, id);
    values.put(MentionsSQLiteHelper.COLUMN_NAME, status.getUser().getName());
    values.put(MentionsSQLiteHelper.COLUMN_PRO_PIC, status.getUser().getOriginalProfileImageURL());
    values.put(MentionsSQLiteHelper.COLUMN_SCREEN_NAME, status.getUser().getScreenName());
    values.put(MentionsSQLiteHelper.COLUMN_TIME, time);
    values.put(MentionsSQLiteHelper.COLUMN_RETWEETER, originalName);
    values.put(MentionsSQLiteHelper.COLUMN_UNREAD, 1);
    values.put(MentionsSQLiteHelper.COLUMN_PIC_URL, media);
    values.put(MentionsSQLiteHelper.COLUMN_URL, otherUrl);
    values.put(MentionsSQLiteHelper.COLUMN_USERS, users);
    values.put(MentionsSQLiteHelper.COLUMN_HASHTAGS, hashtags);

    try {
        database.insert(MentionsSQLiteHelper.TABLE_MENTIONS, null, values);
    } catch (Exception e) {
        open();
        database.insert(MentionsSQLiteHelper.TABLE_MENTIONS, null, values);
    }
}

From source file:com.klinker.android.twitter.data.sq_lite.MentionsDataSource.java

License:Apache License

public synchronized int insertTweets(List<Status> statuses, int account) {

    ContentValues[] valueses = new ContentValues[statuses.size()];

    for (int i = 0; i < statuses.size(); i++) {
        Status status = statuses.get(i);

        ContentValues values = new ContentValues();
        String originalName = "";
        long id = status.getId();
        long time = status.getCreatedAt().getTime();

        String[] html = TweetLinkUtils.getLinksInStatus(status);
        String text = html[0];//from  www.  j a va2 s .  com
        String media = html[1];
        String otherUrl = html[2];
        String hashtags = html[3];
        String users = html[4];

        values.put(MentionsSQLiteHelper.COLUMN_ACCOUNT, account);
        values.put(MentionsSQLiteHelper.COLUMN_TEXT, text);
        values.put(MentionsSQLiteHelper.COLUMN_TWEET_ID, id);
        values.put(MentionsSQLiteHelper.COLUMN_NAME, status.getUser().getName());
        values.put(MentionsSQLiteHelper.COLUMN_PRO_PIC, status.getUser().getOriginalProfileImageURL());
        values.put(MentionsSQLiteHelper.COLUMN_SCREEN_NAME, status.getUser().getScreenName());
        values.put(MentionsSQLiteHelper.COLUMN_TIME, time);
        values.put(MentionsSQLiteHelper.COLUMN_RETWEETER, originalName);
        values.put(MentionsSQLiteHelper.COLUMN_UNREAD, 1);
        values.put(MentionsSQLiteHelper.COLUMN_PIC_URL, media);
        values.put(MentionsSQLiteHelper.COLUMN_URL, otherUrl);
        values.put(MentionsSQLiteHelper.COLUMN_USERS, users);
        values.put(MentionsSQLiteHelper.COLUMN_HASHTAGS, hashtags);

        valueses[i] = values;
    }

    return insertMultiple(valueses);
}

From source file:com.klinker.android.twitter.ui.tweet_viewer.fragments.TweetFragment.java

License:Apache License

public void getInfo(final View favButton, final TextView favCount, final TextView retweetCount,
        final long tweetId, final View retweetButton) {

    Thread getInfo = new Thread(new Runnable() {
        @Override// ww  w . ja v  a  2s.  com
        public void run() {
            String location = "";
            String via = "";
            long realTime = 0;
            boolean retweetedByMe = false;
            try {
                Twitter twitter = Utils.getTwitter(context, settings);

                TwitterMultipleImageHelper helper = new TwitterMultipleImageHelper();
                status = twitter.showStatus(tweetId);

                ArrayList<String> i = new ArrayList<String>();

                if (picture) {
                    i = helper.getImageURLs(status, twitter);
                }

                final ArrayList<String> images = i;

                GeoLocation loc = status.getGeoLocation();
                try {
                    Geocoder geocoder = new Geocoder(context, Locale.getDefault());
                    List<Address> addresses = geocoder.getFromLocation(loc.getLatitude(), loc.getLongitude(),
                            1);
                    if (addresses.size() > 0) {
                        Address address = addresses.get(0);
                        location += address.getLocality() + ", " + address.getCountryName();
                    } else {
                        location = "";
                    }
                } catch (Exception x) {
                    location = "";
                }

                via = android.text.Html.fromHtml(status.getSource()).toString();

                final String sfavCount;
                if (status.isRetweet()) {
                    twitter4j.Status status2 = status.getRetweetedStatus();
                    via = android.text.Html.fromHtml(status2.getSource()).toString();
                    realTime = status2.getCreatedAt().getTime();
                    sfavCount = status2.getFavoriteCount() + "";
                } else {
                    realTime = status.getCreatedAt().getTime();
                    sfavCount = status.getFavoriteCount() + "";
                }

                retweetedByMe = status.isRetweetedByMe();
                final String retCount = "" + status.getRetweetCount();

                final String timeDisplay;

                if (!settings.militaryTime) {
                    timeDisplay = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US).format(realTime)
                            + " " + DateFormat.getTimeInstance(DateFormat.SHORT, Locale.US).format(realTime);
                } else {
                    timeDisplay = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.GERMAN).format(realTime)
                            + " "
                            + DateFormat.getTimeInstance(DateFormat.SHORT, Locale.GERMAN).format(realTime);
                }
                final String fVia = " " + getResources().getString(R.string.via) + " " + via;
                final String fLoc = location.equals("") ? "" : "\n" + location;

                final boolean fRet = retweetedByMe;
                final long fTime = realTime;
                final Status fStatus = status;
                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {

                        // you can't retweet a protected account
                        if (status.getUser().isProtected()) {
                            retweetButton.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    Toast.makeText(context, getString(R.string.protected_account),
                                            Toast.LENGTH_SHORT).show();
                                }
                            });
                        }

                        retweetCount.setText(" " + retCount);

                        if (retweetButton instanceof ImageButton) {
                            if (fRet) {
                                if (!settings.addonTheme) {
                                    ((ImageButton) retweetButton)
                                            .setColorFilter(context.getResources().getColor(R.color.app_color));
                                } else {
                                    ((ImageButton) retweetButton).setColorFilter(settings.accentInt);
                                }
                            } else {
                                ((ImageButton) retweetButton).clearColorFilter();
                            }
                        } else {
                            if (fRet) {
                                if (!settings.addonTheme) {
                                    retweetButton.setBackgroundColor(
                                            context.getResources().getColor(R.color.app_color));
                                } else {
                                    retweetButton.setBackgroundColor(settings.accentInt);
                                }
                            } else {
                                retweetButton.setBackgroundColor(
                                        getResources().getColor(android.R.color.transparent));
                            }
                        }

                        timetv.setText(timeDisplay + fVia);
                        timetv.append(fLoc);

                        favCount.setText(" " + sfavCount);

                        if (favButton instanceof ImageButton) {
                            if (fStatus.isFavorited()) {
                                TypedArray a = context.getTheme()
                                        .obtainStyledAttributes(new int[] { R.attr.favoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();

                                if (!settings.addonTheme) {
                                    ((ImageButton) favButton)
                                            .setColorFilter(context.getResources().getColor(R.color.app_color));
                                } else {
                                    ((ImageButton) favButton).setColorFilter(settings.accentInt);
                                }

                                ((ImageButton) favButton)
                                        .setImageDrawable(context.getResources().getDrawable(resource));
                                isFavorited = true;
                            } else {
                                TypedArray a = context.getTheme()
                                        .obtainStyledAttributes(new int[] { R.attr.notFavoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();

                                ((ImageButton) favButton)
                                        .setImageDrawable(context.getResources().getDrawable(resource));
                                isFavorited = false;

                                ((ImageButton) favButton).clearColorFilter();
                            }
                        } else {
                            if (fStatus.isFavorited()) {
                                TypedArray a = context.getTheme()
                                        .obtainStyledAttributes(new int[] { R.attr.favoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();

                                if (!settings.addonTheme) {
                                    favButton.setBackgroundColor(
                                            context.getResources().getColor(R.color.app_color));
                                } else {
                                    favButton.setBackgroundColor(settings.accentInt);
                                }

                                isFavorited = true;
                            } else {
                                isFavorited = false;

                                favButton.setBackgroundColor(
                                        getResources().getColor(android.R.color.transparent));
                            }
                        }

                        for (String s : images) {
                            Log.v("talon_image", s);
                        }
                        if (images.size() > 1) {
                            Log.v("talon_images", "size: " + images.size());
                            try {
                                mAttacher.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {
                                    @Override
                                    public void onViewTap(View view, float x, float y) {
                                        Intent viewPics = new Intent(context, ViewPictures.class);
                                        viewPics.putExtra("images", images);
                                        startActivity(viewPics);
                                    }
                                });
                            } catch (Exception e) {
                                // addon theme without the attacher
                                profilePic.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {
                                        Intent viewPics = new Intent(context, ViewPictures.class);
                                        viewPics.putExtra("images", images);
                                        startActivity(viewPics);
                                    }
                                });
                            }
                        }

                    }
                });
            } catch (Exception e) {

            }
        }
    });

    getInfo.setPriority(Thread.MAX_PRIORITY);
    getInfo.start();
}

From source file:com.learnncode.twitter.TweetViewHolder.java

License:Apache License

public void populateView(final Context context, final Status status) {
    mContext = context;/* ww w .ja v  a2  s. c  om*/
    if (status.getUser().getId() != AppSettings.getTwitterUserId(mContext)) {

        retweetTextView.setEnabled(true);

    } else {
        retweetTextView.setEnabled(false);
    }

    retweetTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.retweet_action_selector, 0);

    aQuery = new AQuery(mContext);
    aQuery.id(userProfileImageView).image(status.getUser().getBiggerProfileImageURL(), true, true,
            userProfileImageView.getWidth(), 0, null, 0);
    userNameTextView.setText(status.getUser().getName());
    twitterHandlerTextView.setText("@" + status.getUser().getScreenName());
    setMessage(mContext, tweetTextView, status.getText());
    favoriteTextView.setText(" " + status.getFavoriteCount());
    retweetTextView.setText(" " + status.getRetweetCount());

    timeTextView.setText(AppUtilities.getConvertDate(status.getCreatedAt().toString()));

    twitter4j.MediaEntity[] entity = status.getMediaEntities();
    int count = entity.length;
    if (count > 0) {
        imageContainer.setVisibility(View.VISIBLE);
        imageWithTweet.setVisibility(View.VISIBLE);
        for (int i = 0; i < count; i++) {
            mImageLink = entity[i].getMediaURL();
            aQuery.id(imageWithTweet).image(entity[i].getMediaURL(), true, true,
                    userProfileImageView.getWidth(), 0, null, 0);
        }
    } else {
        imageContainer.setVisibility(View.GONE);
        imageWithTweet.setVisibility(View.GONE);
    }

    imageWithTweet.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(context, UIImagePreview.class);
            intent.putExtra("url", mImageLink);
            context.startActivity(intent);

        }
    });
}

From source file:com.lorenzobraghetto.speakbird.View.MentionsAdapter.java

License:Open Source License

public View getView(int position, View convertView, ViewGroup parent) {

    ViewHolder holder;/*from   w ww .  ja v  a2  s.c om*/
    if (convertView == null) {
        holder = new ViewHolder();
        convertView = inflater.inflate(R.layout.mentionslist, null);

        holder.imgViewLogo = (ImageView) convertView.findViewById(R.id.personImage);
        holder.txtViewNick = (TextView) convertView.findViewById(R.id.personName);
        holder.txtViewText = (TextView) convertView.findViewById(R.id.testo);
        holder.txtViewTime = (TextView) convertView.findViewById(R.id.time);
        holder.background = (RelativeLayout) convertView.findViewById(R.id.layout);

        convertView.setTag(holder);
    } else
        holder = (ViewHolder) convertView.getTag();

    long d;
    String urlimg;
    String nick;
    String text;

    if (type.compareTo("mentions") == 0) {
        Status bean = (Status) itemList.get(position);
        d = bean.getCreatedAt().getTime();
        urlimg = bean.getUser().getProfileImageURL() + "";
        nick = bean.getUser().getScreenName();
        text = bean.getText();
    } else {
        DirectMessage bean = (DirectMessage) itemList.get(position);
        d = bean.getCreatedAt().getTime();
        urlimg = bean.getSender().getProfileImageURL() + "";
        nick = bean.getSender().getScreenName();
        text = bean.getText();
    }

    long now = System.currentTimeMillis();

    long elapsed = now - d;
    int minutes = (int) ((elapsed / (1000 * 60)) % 60);
    int hours = (int) ((elapsed / (1000 * 60 * 60)) % 24);
    int days = (int) ((elapsed / (1000 * 60 * 60 * 24)));

    UrlImageViewHelper.setUrlDrawable(holder.imgViewLogo, urlimg);

    holder.txtViewNick.setText("@" + nick);
    holder.txtViewText.setText(text);
    if (days > 0 && hours > 0 && minutes > 0)
        holder.txtViewTime.setText(days + "d " + hours + "h " + minutes + "m ");
    else if (hours > 0 && minutes > 0)
        holder.txtViewTime.setText(hours + "h " + minutes + "m ");
    else
        holder.txtViewTime.setText(minutes + "m ");

    if (position == itemColored) {
        holder.background.setBackgroundColor(0xffa4a4a4);

    } else if (first == d) {
        holder.background
                .setBackgroundDrawable(context.getResources().getDrawable(R.drawable.sfondotweetunonove));
    } else {
        holder.background.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.sfondotweetnove));
    }

    return convertView;
}

From source file:com.marpies.ane.twitter.utils.StatusUtils.java

License:Apache License

public static JSONObject getJSON(Status status) throws JSONException {
    JSONObject statusJSON = new JSONObject();
    statusJSON.put("id", status.getId());
    statusJSON.put("idStr", String.valueOf(status.getId()));
    statusJSON.put("text", status.getText());
    statusJSON.put("replyToUserID", status.getInReplyToUserId());
    statusJSON.put("replyToStatusID", status.getInReplyToStatusId());
    statusJSON.put("likesCount", status.getFavoriteCount());
    statusJSON.put("retweetCount", status.getRetweetCount());
    statusJSON.put("isRetweet", status.isRetweet());
    statusJSON.put("isSensitive", status.isPossiblySensitive());
    statusJSON.put("createdAt", status.getCreatedAt());
    Status retweetedStatus = status.getRetweetedStatus();
    if (retweetedStatus != null) {
        statusJSON.put("retweetedStatus", getJSON(retweetedStatus));
    }//from   ww w. ja  v a2s . c o  m
    User user = status.getUser();
    if (user != null) {
        statusJSON.put("user", UserUtils.getJSON(user));
    }
    return statusJSON;
}

From source file:com.michaelfitzmaurice.clocktwerk.TweetResponder.java

License:Apache License

public Collection<Status> getNewMentions() throws TweetException {

    long sinceId = lastSeenMention();
    try {/*from   w  ww .ja va2s  .  co m*/
        LOG.info("Checking for new Twitter mentions of {} since Tweet {}", myScreenName, sinceId);
        Paging paging = new Paging(sinceId);
        ResponseList<Status> mentions = twitterClient.getMentionsTimeline(paging);
        int numberOfMentions = mentions.size();
        LOG.info("Found {} new mentions", numberOfMentions);
        for (Status status : mentions) {
            User user = status.getUser();
            String mentionSummary = format("Date:%s, ID:%s, From:%s (%s), Text:'%s'", status.getCreatedAt(),
                    status.getId(), user.getScreenName(), user.getName(), status.getText());
            LOG.debug("New mention: [{}]", mentionSummary);
        }
        return mentions;
    } catch (TwitterException e) {
        throw new TweetException("Error getting Twitter mentions", e);
    }

    // TODO handle paging
}

From source file:com.mothsoft.alexis.engine.retrieval.TwitterRetrievalTaskImpl.java

License:Apache License

private void handleSourceImpl(final TwitterSource twitterSource) {
    final SocialConnection socialConnection = twitterSource.getSocialConnection();
    final AccessToken accessToken = new AccessToken(socialConnection.getOauthToken(),
            socialConnection.getOauthTokenSecret());

    final List<Status> statuses = this.twitterService.getHomeTimeline(accessToken,
            twitterSource.getLastTweetId(), (short) 800);

    if (statuses != null && statuses.size() > 0) {
        logger.info("Twitter retrieval found " + statuses.size() + " Tweets for user: "
                + socialConnection.getRemoteUsername());

        // the newest tweet in the timeline will be our starting point for
        // the next fetch
        twitterSource.setLastTweetId(statuses.get(0).getId());

        // import these in reverse order to ensure newest ones have the
        // highest document IDs
        Collections.reverse(statuses);

        final Long userId = twitterSource.getUserId();
        final User user = this.userDao.get(userId);

        for (final Status status : statuses) {
            final Long tweetId = status.getId();

            Tweet tweet = this.tweetDao.getTweetByRemoteTweetId(tweetId);
            final boolean isAdd = (tweet == null);

            if (isAdd) {
                // TODO - is this right?
                // Twitter allows 2 different styles of retweets. The
                // ones that are actually retweets show as tweeted by the
                // original user. Others may show
                // "RT @original thing original said" tweeted
                // by the new person
                final boolean retweet = status.isRetweet();

                final twitter4j.User tweeter;
                final String text;
                twitter4j.User retweeter = null;

                final List<TweetLink> links;
                final List<TweetMention> mentions;
                final List<TweetHashtag> hashtags;

                if (retweet) {
                    tweeter = status.getRetweetedStatus().getUser();
                    text = status.getRetweetedStatus().getText();
                    retweeter = status.getUser();
                    links = readLinks(status.getRetweetedStatus());
                    mentions = readMentions(status.getRetweetedStatus());
                    hashtags = readHashtags(status.getRetweetedStatus());
                } else {
                    tweeter = status.getUser();
                    text = status.getText();
                    links = readLinks(status);
                    mentions = readMentions(status);
                    hashtags = readHashtags(status);
                }/*from w w w  .j a v a 2s . co m*/

                final URL profileImageUrl = tweeter.getProfileImageUrlHttps();
                final Date createdAt = status.getCreatedAt();

                tweet = new Tweet(tweetId, createdAt, tweeter.getScreenName(), tweeter.getName(),
                        profileImageUrl, text, links, mentions, hashtags, retweet,
                        retweet ? retweeter.getScreenName() : null);
                this.documentDao.add(tweet);
            }

            final DocumentUser documentUser = new DocumentUser(tweet, user);

            if (isAdd || !tweet.getDocumentUsers().contains(documentUser)) {
                tweet.getDocumentUsers().add(new DocumentUser(tweet, user));
                this.documentDao.update(tweet);
            }
        }
    } else {
        logger.info("Twitter retrieval found no Tweets for user: " + socialConnection.getRemoteUsername());
    }

    twitterSource.setRetrievalDate(new Date());
    this.sourceDao.update(twitterSource);
}

From source file:com.mycompany.omnomtweets.Search.java

public static boolean writeToStdErr(Status tweet) {
    //System.out.println("Writing " + tweets.size() + " tweets");
    boolean success = true;
    if (tweet != null) {
        String tweetText;/*w ww .j a v a  2s  . c  om*/
        String idOfRetweetee = "";
        if (tweet.getRetweetedStatus() != null) {
            tweetText = "RT " + tweet.getRetweetedStatus().getText();
            idOfRetweetee = "" + tweet.getRetweetedStatus().getUser().getScreenName();
            //System.out.println("retweeted" + tweetText);
        } else {
            tweetText = tweet.getText();
        }
        String urlText = "";
        if (tweet.getURLEntities().length > 0) {
            for (URLEntity url : tweet.getURLEntities()) {
                if (url.getExpandedURL() != null) {
                    urlText += url.getExpandedURL() + " ";
                    tweetText = tweetText.replace(url.getURL(), url.getExpandedURL());
                    //System.out.println("Expanded URL " + url.getExpandedURL());
                } else {
                    urlText += url.getURL() + " ";
                    //System.out.println("URL " + url.getURL());
                }
            }
        }
        if (tweet.getMediaEntities().length > 0) {
            for (MediaEntity media : tweet.getMediaEntities()) {
                if (media.getExpandedURL() != null) {
                    urlText += media.getExpandedURL() + " ";
                    tweetText = tweetText.replace(media.getMediaURL(), media.getExpandedURL());
                    //System.out.println("Expanded URL " + media.getExpandedURL());
                } else {
                    urlText += media.getMediaURL() + " ";
                    //System.out.println("URL " + media.getMediaURL());
                }
            }
        }
        String encodedText = tweetText.replaceAll("\"", "\"\"");
        encodedText = encodedText.replaceAll("\\s", " ");
        String writeMe = "\"" + encodedText + "\"," + urlText + "," + tweet.getUser().getId() + ","
                + tweet.getId() + "," + candidate.name + "," + sdf.format(tweet.getCreatedAt()) + ","
                + idOfRetweetee + "\n";
        System.err.print(writeMe);
        //writeTweets.write(writeMe);
    }
    return success;
}

From source file:com.mycompany.omnomtweets.Search.java

/**
 * Method to write the tweets to file, base 64 encoded tweet text.
 * @param tweets the tweets to be written
 * @param filename the file to write the tweets into
 * @return true unless something bad happens
 *///from  www . ja  v  a 2  s  .  c o  m
public static boolean writeTweetsToFile(List<Status> tweets, String filename) {
    //System.out.println("Writing " + tweets.size() + " tweets");
    boolean success = true;
    try {
        FileWriter addTweets = new FileWriter(new File(filename), true);
        if (tweets != null && tweets.size() > 0) {
            for (Status tweet : tweets) {
                String tweetText;
                String idOfRetweetee = "";
                if (tweet.getRetweetedStatus() != null) {
                    tweetText = "RT " + tweet.getRetweetedStatus().getText();
                    idOfRetweetee = "" + tweet.getRetweetedStatus().getUser().getScreenName();
                    //System.out.println("retweeted" + tweetText);
                } else {
                    tweetText = tweet.getText();
                }
                String urlText = "";
                if (tweet.getURLEntities().length > 0) {
                    for (URLEntity url : tweet.getURLEntities()) {
                        if (url.getExpandedURL() != null) {
                            urlText += url.getExpandedURL() + " ";
                            tweetText = tweetText.replace(url.getURL(), url.getExpandedURL());
                            //System.out.println("Expanded URL " + url.getExpandedURL());
                        } else {
                            urlText += url.getURL() + " ";
                            //System.out.println("URL " + url.getURL());    
                        }
                    }
                }
                if (tweet.getMediaEntities().length > 0) {
                    for (MediaEntity media : tweet.getMediaEntities()) {
                        if (media.getExpandedURL() != null) {
                            urlText += media.getExpandedURL() + " ";
                            tweetText = tweetText.replace(media.getMediaURL(), media.getExpandedURL());
                            //System.out.println("Expanded URL " + media.getExpandedURL());
                        } else {
                            urlText += media.getMediaURL() + " ";
                            //System.out.println("URL " + media.getMediaURL());    
                        }
                    }
                }
                String encodedText = tweetText.replaceAll("\"", "\"\"");
                encodedText = encodedText.replaceAll("\n", " ");
                String writeMe = "\"" + encodedText + "\"," + urlText + "," + tweet.getUser().getId() + ","
                        + tweet.getId() + "," + candidate.name + "," + tweet.getCreatedAt() + ","
                        + idOfRetweetee + "\n";
                //System.out.println(writeMe);
                addTweets.write(writeMe);
            }
        }
        addTweets.close();
    } catch (IOException ex) {
        //System.out.println("Something broke lol");
        success = false;
    }
    return success;
}