Example usage for twitter4j.conf ConfigurationBuilder build

List of usage examples for twitter4j.conf ConfigurationBuilder build

Introduction

In this page you can find the example usage for twitter4j.conf ConfigurationBuilder build.

Prototype

public Configuration build() 

Source Link

Usage

From source file:org.vsepml.storm.twitter.StormTwitterStreamSpout.java

License:Apache License

@Override
public void open(Map map, TopologyContext topologyContext, SpoutOutputCollector spoutOutputCollector) {
    this.collector = spoutOutputCollector;
    queue = new LinkedBlockingQueue<Status>(1000);

    StatusListener listener = new StatusListener() {
        public void onStatus(Status status) {
            queue.offer(status);//  w  w  w  .  j a  va 2  s  .c o m
        }

        @Override
        public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
        }

        @Override
        public void onTrackLimitationNotice(int numberOfLimitedStatuses) {
        }

        @Override
        public void onScrubGeo(long l, long l1) {
        }

        @Override
        public void onStallWarning(StallWarning stallWarning) {
        }

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

    ConfigurationBuilder twitterConf = new ConfigurationBuilder();
    twitterConf.setIncludeEntitiesEnabled(true);
    twitterConf.setUseSSL(true);
    twitterConf.setUserStreamRepliesAllEnabled(true);
    twitterConf.setOAuthAccessToken(accessToken);
    twitterConf.setOAuthAccessTokenSecret(accessTokenSecret);
    twitterConf.setOAuthConsumerKey(consumerKey);
    twitterConf.setOAuthConsumerSecret(consumerSecret);

    twitterStream = new TwitterStreamFactory(twitterConf.build()).getInstance();
    twitterStream.addListener(listener);
    // sample() method internally creates a thread which manipulates TwitterStream and calls these adequate listener methods continuously.
    twitterStream.sample();
}

From source file:org.wso2.carbon.connector.twitter.TwitterClientLoader.java

License:Open Source License

public Twitter loadApiClient() throws TwitterException {
    Twitter twitter;/* w  w  w.j  a v  a2 s.  co  m*/
    if (messageContext.getProperty(TwitterConnectConstants.TWITTER_USER_CONSUMER_KEY) != null
            && messageContext.getProperty(TwitterConnectConstants.TWITTER_USER_CONSUMER_SECRET) != null
            && messageContext.getProperty(TwitterConnectConstants.TWITTER_USER_ACCESS_TOKEN) != null
            && messageContext.getProperty(TwitterConnectConstants.TWITTER_USER_ACCESS_TOKEN_SECRET) != null) {
        ConfigurationBuilder build = new ConfigurationBuilder();
        build.setJSONStoreEnabled(true);
        build.setOAuthAccessToken(
                messageContext.getProperty(TwitterConnectConstants.TWITTER_USER_ACCESS_TOKEN).toString());
        build.setOAuthAccessTokenSecret(messageContext
                .getProperty(TwitterConnectConstants.TWITTER_USER_ACCESS_TOKEN_SECRET).toString());
        build.setOAuthConsumerKey(
                messageContext.getProperty(TwitterConnectConstants.TWITTER_USER_CONSUMER_KEY).toString());
        build.setOAuthConsumerSecret(
                messageContext.getProperty(TwitterConnectConstants.TWITTER_USER_CONSUMER_SECRET).toString());
        twitter = new TwitterFactory(build.build()).getInstance();
        twitter.verifyCredentials();
    } else {
        twitter = new TwitterFactory().getInstance();
    }
    return twitter;
}

From source file:org.wso2.carbon.identity.authenticator.twitter.TwitterAuthenticator.java

License:Open Source License

/**
 * Initiate the authentication request/*  w  ww  .j a  v a 2 s .  c om*/
 */
@Override
protected void initiateAuthenticationRequest(HttpServletRequest request, HttpServletResponse response,
        AuthenticationContext context) throws AuthenticationFailedException {
    ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
    Map<String, String> authenticatorProperties = context.getAuthenticatorProperties();
    String apiKey = authenticatorProperties.get(TwitterAuthenticatorConstants.TWITTER_API_KEY);
    String apiSecret = authenticatorProperties.get(TwitterAuthenticatorConstants.TWITTER_API_SECRET);
    configurationBuilder.setIncludeEmailEnabled(true);
    Twitter twitter = new TwitterFactory(configurationBuilder.build()).getInstance();
    twitter.setOAuthConsumer(apiKey, apiSecret);
    try {
        String queryParams = FrameworkUtils.getQueryStringWithFrameworkContextId(context.getQueryParams(),
                context.getCallerSessionKey(), context.getContextIdentifier());
        String callbackURL = getCallbackUrl(authenticatorProperties);
        RequestToken requestToken = twitter.getOAuthRequestToken(callbackURL.toString());
        String subStr = queryParams
                .substring(queryParams.indexOf(TwitterAuthenticatorConstants.TWITTER_SESSION_DATA_KEY + "="));
        String sessionDK = subStr
                .substring(subStr.indexOf(TwitterAuthenticatorConstants.TWITTER_SESSION_DATA_KEY + "="),
                        subStr.indexOf("&"))
                .replace((TwitterAuthenticatorConstants.TWITTER_SESSION_DATA_KEY + "="), "");
        request.getSession().setAttribute(TwitterAuthenticatorConstants.TWITTER_SESSION_DATA_KEY, sessionDK);
        request.getSession().setAttribute(TwitterAuthenticatorConstants.TWITTER_REQUEST_TOKEN, requestToken);
        request.getSession().setAttribute(TwitterAuthenticatorConstants.AUTHENTICATOR_NAME.toLowerCase(),
                twitter);
        response.sendRedirect(requestToken.getAuthenticationURL());
    } catch (TwitterException e) {
        log.error("Exception while sending to the Twitter login page.", e);
        throw new AuthenticationFailedException(e.getMessage(), e);
    } catch (IOException e) {
        log.error("Exception while sending to the Twitter login page.", e);
        throw new AuthenticationFailedException(e.getMessage(), e);
    }
}

From source file:org.wso2.carbon.inbound.custom.poll.TwitterStreamData.java

License:Open Source License

/**
 * Setting up a connection with Twitter Stream API with the given
 * credentials/*from w ww  .j av a  2 s .c o m*/
 *
 * @throws TwitterException
 */
private void setupConnection() throws TwitterException {
    if (log.isDebugEnabled()) {
        log.debug("Starting to setup the connection with the twitter streaming endpoint");
    }
    ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
    configurationBuilder.setDebugEnabled(true).setOAuthConsumerKey(consumerKey)
            .setOAuthConsumerSecret(consumerSecret).setOAuthAccessToken(accessToken)
            .setOAuthAccessTokenSecret(accessSecret);
    StatusListener statusStreamsListener;
    UserStreamListener userStreamListener;
    SiteStreamsListener siteStreamslistener;
    TwitterStream twitterStream = new TwitterStreamFactory(configurationBuilder.build()).getInstance();
    String twitterOperation = properties.getProperty(TwitterConstant.TWITTER_OPERATION);
    if (twitterOperation.equals(TwitterConstant.FILTER_STREAM_OPERATION)
            || twitterOperation.equals(TwitterConstant.FIREHOSE_STREAM_OPERATION)
            || twitterOperation.equals(TwitterConstant.LINK_STREAM_OPERATION)
            || twitterOperation.equals(TwitterConstant.SAMPLE_STREAM_OPERATION)) {
        statusStreamsListener = new StatusListenerImpl();
        twitterStream.addListener(statusStreamsListener);
    } else if (twitterOperation.equals(TwitterConstant.USER_STREAM_OPERATION)) {
        userStreamListener = new UserStreamListenerImpl();
        twitterStream.addListener(userStreamListener);
    } else if (twitterOperation.equals(TwitterConstant.SITE_STREAM_OPERATION)) {
        siteStreamslistener = new siteStreamsListenerImpl();
        twitterStream.addListener(siteStreamslistener);
    } else {
        handleException("The operation :" + twitterOperation + " not found");
    }

    /* Synchronously retrieves public statuses that match one or more filter predicates.*/
    if ((properties.getProperty(TwitterConstant.TWITTER_OPERATION))
            .equals(TwitterConstant.FILTER_STREAM_OPERATION)) {
        FilterQuery query = new FilterQuery();
        if (languages != null) {
            query.language(languages);
        }
        if (tracks != null) {
            query.track(tracks);
        }
        if (follow != null) {
            query.follow(follow);
        }
        if (filterLevel != null) {
            query.filterLevel(filterLevel);
        }
        query.count(count);
        twitterStream.filter(query);
    }

    /* Returns a small random sample of all public statuses. */
    if ((properties.getProperty(TwitterConstant.TWITTER_OPERATION))
            .equals(TwitterConstant.SAMPLE_STREAM_OPERATION)) {

        if (languages != null) {
            if (languages.length == 1) {
                twitterStream.sample(languages[1]);
            } else {
                handleException("A language can be used for the sample operation");
            }
        }
        twitterStream.sample();
    }
    /* Asynchronously retrieves all public statuses.*/
    if ((properties.getProperty(TwitterConstant.TWITTER_OPERATION))
            .equals(TwitterConstant.FIREHOSE_STREAM_OPERATION)) {
        if (countParam != null) {
            twitterStream.firehose(count);
        }
    }
    /*
     User Streams provide a stream of data and events specific to the
     authenticated user.This provides to access the Streams messages for a
     single user.
     */
    if ((properties.getProperty(TwitterConstant.TWITTER_OPERATION))
            .equals(TwitterConstant.USER_STREAM_OPERATION)) {
        if (tracks != null) {
            twitterStream.user(tracks);
        }
        twitterStream.user();
    }
    /*
     * Link Streams provide asynchronously retrieves all statuses containing 'http:' and 'https:'.
     */
    if ((properties.getProperty(TwitterConstant.TWITTER_OPERATION))
            .equals(TwitterConstant.LINK_STREAM_OPERATION)) {
        if (countParam != null) {
            twitterStream.links(count);
        }
    }
    /*
     * User Streams provide a stream of data and events specific to the
     * authenticated user.This provides to access the Streams messages for a
     * single user.
     */
    if ((properties.getProperty(TwitterConstant.TWITTER_OPERATION))
            .equals(TwitterConstant.RETWEET_STREAM_OPERATION)) {
        twitterStream.retweet();
    }
    /*
     * Site Streams allows services, such as web sites or mobile push
     * services, to receive real-time updates for a large number of users.
     * Events may be streamed for any user who has granted OAuth access to
     * your application. Desktop applications or applications with few users
     * should use user streams.
     */
    if ((properties.getProperty(TwitterConstant.TWITTER_OPERATION))
            .equals(TwitterConstant.SITE_STREAM_OPERATION)) {
        twitterStream.site(withFollowings, follow);
    }

}

From source file:org.wso2.carbon.inbound.twitter.poll.TwitterStreamData.java

License:Open Source License

/**
 * Setting up a connection with Twitter Stream API with the given
 * credentials//from w  w w . j  a  va2 s .  co  m
 *
 * @throws TwitterException
 */
private void setupConnection() throws TwitterException {
    if (log.isDebugEnabled()) {
        log.debug("Starting to setup the connection with the twitter streaming endpoint");
    }
    ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
    configurationBuilder.setDebugEnabled(true).setJSONStoreEnabled(true).setOAuthConsumerKey(consumerKey)
            .setOAuthConsumerSecret(consumerSecret).setOAuthAccessToken(accessToken)
            .setOAuthAccessTokenSecret(accessSecret);
    StatusListener statusStreamsListener;
    UserStreamListener userStreamListener;
    SiteStreamsListener siteStreamslistener;
    twitterStream = new TwitterStreamFactory(configurationBuilder.build()).getInstance();
    String twitterOperation = properties.getProperty(TwitterConstant.TWITTER_OPERATION);
    if (twitterOperation.equals(TwitterConstant.FILTER_STREAM_OPERATION)
            || twitterOperation.equals(TwitterConstant.FIREHOSE_STREAM_OPERATION)
            || twitterOperation.equals(TwitterConstant.LINK_STREAM_OPERATION)
            || twitterOperation.equals(TwitterConstant.SAMPLE_STREAM_OPERATION)
            || twitterOperation.equals(TwitterConstant.RETWEET_STREAM_OPERATION)) {
        statusStreamsListener = new StatusListenerImpl();
        twitterStream.addListener(statusStreamsListener);
    } else if (twitterOperation.equals(TwitterConstant.USER_STREAM_OPERATION)) {
        userStreamListener = new UserStreamListenerImpl();
        twitterStream.addListener(userStreamListener);
    } else if (twitterOperation.equals(TwitterConstant.SITE_STREAM_OPERATION)) {
        siteStreamslistener = new siteStreamsListenerImpl();
        twitterStream.addListener(siteStreamslistener);
    } else {
        handleException("The operation :" + twitterOperation + " not found");
    }

    /* Synchronously retrieves public statuses that match one or more filter predicates.*/
    if ((properties.getProperty(TwitterConstant.TWITTER_OPERATION))
            .equals(TwitterConstant.FILTER_STREAM_OPERATION)) {
        FilterQuery query = new FilterQuery();
        if (languages != null) {
            query.language(languages);
        }
        if (tracks != null) {
            query.track(tracks);
        }
        if (follow != null) {
            query.follow(follow);
        }
        if (locations != null) {
            query.locations(locations);
        }
        if (filterLevel != null) {
            query.filterLevel(filterLevel);
        }
        if (follow == null & tracks == null & locations == null) {
            handleException("At least follow, locations, or track must be specified.");
        }
        query.count(count);
        twitterStream.filter(query);
    }

    /* Returns a small random sample of all public statuses. */
    if ((properties.getProperty(TwitterConstant.TWITTER_OPERATION))
            .equals(TwitterConstant.SAMPLE_STREAM_OPERATION)) {

        if (languages != null) {
            if (languages.length == 1) {
                twitterStream.sample(languages[1]);
            } else {
                handleException("A language can be used for the sample operation");
            }
        } else {
            twitterStream.sample();
        }
    }
    /* Asynchronously retrieves all public statuses.*/
    if ((properties.getProperty(TwitterConstant.TWITTER_OPERATION))
            .equals(TwitterConstant.FIREHOSE_STREAM_OPERATION)) {
        if (countParam != null) {
            twitterStream.firehose(count);
        }
    }
    /*
     User Streams provide a stream of data and events specific to the
    authenticated user.This provides to access the Streams messages for a
    single user.
    */
    if ((properties.getProperty(TwitterConstant.TWITTER_OPERATION))
            .equals(TwitterConstant.USER_STREAM_OPERATION)) {
        if (tracks != null) {
            twitterStream.user(tracks);
        } else {
            twitterStream.user();
        }
    }
    /*
     * Link Streams provide asynchronously retrieves all statuses containing 'http:' and 'https:'.
    */
    if ((properties.getProperty(TwitterConstant.TWITTER_OPERATION))
            .equals(TwitterConstant.LINK_STREAM_OPERATION)) {
        if (countParam != null) {
            twitterStream.links(count);
        }
    }
    /*
     * User Streams provide a stream of data and events specific to the
    * authenticated user.This provides to access the Streams messages for a
    * single user.
    */
    if ((properties.getProperty(TwitterConstant.TWITTER_OPERATION))
            .equals(TwitterConstant.RETWEET_STREAM_OPERATION)) {
        twitterStream.retweet();
    }
    /*
     * Site Streams allows services, such as web sites or mobile push
    * services, to receive real-time updates for a large number of users.
    * Events may be streamed for any user who has granted OAuth access to
    * your application. Desktop applications or applications with few users
    * should use user streams.
    */
    if ((properties.getProperty(TwitterConstant.TWITTER_OPERATION))
            .equals(TwitterConstant.SITE_STREAM_OPERATION)) {
        twitterStream.site(withFollowings, follow);
    }

}

From source file:Origin.Mypage.java

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException, TwitterException {
    response.setContentType("text/html;charset=UTF-8");
    /* TODO output your page here. You may use following sample code. */
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true);/*from   w  w  w  .ja  v  a 2 s  .  c  o m*/
    cb.setOAuthConsumerKey(CONSUMER_KEY);
    cb.setOAuthConsumerSecret(CONSUMER_SECRET);
    cb.setOAuthAccessToken(ACCESS_TOKEN);
    cb.setOAuthAccessTokenSecret(ACCESS_TOKEN_SECRET);
    TwitterFactory tf = new TwitterFactory(cb.build());
    Twitter twitter = tf.getInstance();
    User user = twitter.verifyCredentials();
    request.setCharacterEncoding("UTF-8");
    HttpSession hs = request.getSession();
    UserData ud = (UserData) hs.getAttribute("ud");
    String search = ud.getLine() + "?";
    //String search= request.getParameter("searchtweet");
    Query query = new Query();
    query.setCount(100);
    query.setQuery(search);
    QueryResult queryresult = null;
    try {
        queryresult = twitter.search(query);
    } catch (TwitterException e1) {
        e1.printStackTrace();
    }
    ArrayList<String> userID = new ArrayList<>();
    for (Status tweet : queryresult.getTweets()) {
        userID.add(tweet.getUser().getScreenName());
    }
    ArrayList<String> profileimg = new ArrayList<>();
    for (Status tweet : queryresult.getTweets()) {
        profileimg.add(tweet.getUser().getBiggerProfileImageURL());
    }
    ArrayList<String> username = new ArrayList<>();
    for (Status tweet : queryresult.getTweets()) {
        username.add(tweet.getUser().getName() + "<br>" + "@" + tweet.getUser().getScreenName());
    }
    ArrayList<String> usernameURL = new ArrayList<>();
    for (Status tweet : queryresult.getTweets()) {
        username.add(tweet.getUser().getURL());
    }
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd HH:mm:ss");

    ArrayList<String> resulttweet = new ArrayList<>();
    for (Status tweet : queryresult.getTweets()) {
        resulttweet.add(tweet.getText() + "<br>" + sdf.format(tweet.getCreatedAt()));
    }
    request.setAttribute("search", search);
    request.setAttribute("userID", userID);
    request.setAttribute("profileimg", profileimg);
    request.setAttribute("username", username);
    request.setAttribute("resulttweet", resulttweet);
    request.setAttribute("usernameURL", usernameURL);
    request.getRequestDispatcher("/mypage.jsp").forward(request, response);
}

From source file:Origin.Searchtweet.java

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException, TwitterException {
    response.setContentType("text/html;charset=UTF-8");
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true);// w w w.  j  a  v  a2  s.c  om
    cb.setOAuthConsumerKey(CONSUMER_KEY);
    cb.setOAuthConsumerSecret(CONSUMER_SECRET);
    cb.setOAuthAccessToken(ACCESS_TOKEN);
    cb.setOAuthAccessTokenSecret(ACCESS_TOKEN_SECRET);
    TwitterFactory tf = new TwitterFactory(cb.build());
    Twitter twitter = tf.getInstance();
    User user = twitter.verifyCredentials();
    request.setCharacterEncoding("UTF-8");
    String search = "?" + request.getParameter("searchtweet");
    //String search= request.getParameter("searchtweet");
    Query query = new Query();
    query.setCount(100);
    query.setQuery(search);
    QueryResult queryresult = null;
    try {
        queryresult = twitter.search(query);
    } catch (TwitterException e1) {
        e1.printStackTrace();
    }
    ArrayList<String> userID = new ArrayList<>();
    for (Status tweet : queryresult.getTweets()) {
        userID.add(tweet.getUser().getScreenName());
    }
    ArrayList<String> profileimg = new ArrayList<>();
    for (Status tweet : queryresult.getTweets()) {
        profileimg.add(tweet.getUser().getBiggerProfileImageURL());
    }
    ArrayList<String> username = new ArrayList<>();
    for (Status tweet : queryresult.getTweets()) {
        username.add(tweet.getUser().getName() + "<br>" + "@" + tweet.getUser().getScreenName());
    }
    ArrayList<String> usernameURL = new ArrayList<>();
    for (Status tweet : queryresult.getTweets()) {
        username.add(tweet.getUser().getURL());
    }
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd HH:mm:ss");

    ArrayList<String> resulttweet = new ArrayList<>();
    for (Status tweet : queryresult.getTweets()) {
        resulttweet.add(tweet.getText() + "<br>" + sdf.format(tweet.getCreatedAt()));
    }
    request.setAttribute("search", search);
    request.setAttribute("userID", userID);
    request.setAttribute("profileimg", profileimg);
    request.setAttribute("username", username);
    request.setAttribute("resulttweet", resulttweet);
    request.setAttribute("usernameURL", usernameURL);
    request.getRequestDispatcher("/searchtweet.jsp").forward(request, response);
}

From source file:Origin.Timeline.java

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true);//from  www .  ja v  a 2s  .c  om
    cb.setOAuthConsumerKey(CONSUMER_KEY);
    cb.setOAuthConsumerSecret(CONSUMER_SECRET);
    cb.setOAuthAccessToken(ACCESS_TOKEN);
    cb.setOAuthAccessTokenSecret(ACCESS_TOKEN_SECRET);
    try {
        Twitter twitter = new TwitterFactory(cb.build()).getInstance();
        User user = twitter.verifyCredentials();
        Paging paging = new Paging(1, 200);
        ResponseList<Status> userstatus = twitter.getHomeTimeline(paging);
        request.setAttribute("userstatus", userstatus);
        request.getRequestDispatcher("/timeline.jsp").forward(request, response);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get timeline: " + te.getMessage());
        System.exit(-1);
    }

}

From source file:Origin.Tweet.java

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException, TwitterException {
    response.setContentType("text/html;charset=UTF-8");
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true);//from www  . java 2  s . com
    cb.setOAuthConsumerKey(CONSUMER_KEY);
    cb.setOAuthConsumerSecret(CONSUMER_SECRET);
    cb.setOAuthAccessToken(ACCESS_TOKEN);
    cb.setOAuthAccessTokenSecret(ACCESS_TOKEN_SECRET);
    try {
        Twitter twitter = new TwitterFactory(cb.build()).getInstance();
        User user = twitter.verifyCredentials();
        HttpSession session = request.getSession();
        request.setCharacterEncoding("UTF-8");
        //String tweet = encode(request.getParameter("tweet"));
        String tweet = request.getParameter("tweet");
        Status status = twitter.updateStatus(tweet);
        session.setAttribute("tweet", tweet);
        request.getRequestDispatcher("/tweet.jsp").forward(request, response);
    } catch (TwitterException e1) {
        e1.printStackTrace();
    }
}

From source file:Principal.Tracker_Twitter.java

License:Minecraft Mod Public

public void guardarResultados_Twitter(List<ObjetoBuscar> lista, BD base, int contadorBase, int TokenIndice)
        throws NoSuchAlgorithmException, KeyManagementException {
    int nuevoContadorBase = 0;
    if (contadorBase >= lista.size()) {
        System.out.println("Termino en:" + contadorBase);
    } else {//from   ww w.j  a va 2  s  .  c  om
        System.out.println("---------------------------------------------------------------------:P");

        TrustManager[] trustAllCerts = { new X509TrustManager() {
            public X509Certificate[] getAcceptedIssuers() {
                return null;
            }

            public void checkClientTrusted(X509Certificate[] certs, String authType) {
            }

            public void checkServerTrusted(X509Certificate[] certs, String authType) {
            }
        } };
        SSLContext sc = SSLContext.getInstance("SSL");

        sc.init(null, trustAllCerts, new SecureRandom());

        HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());

        HostnameVerifier allHostsValid = new HostnameVerifier() {
            public boolean verify(String hostname, SSLSession session) {
                return true;
            }
        };
        HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);

        System.out.println("Token : " + TokenIndice);
        System.out.println(consumerKey[TokenIndice]);
        try {
            ConfigurationBuilder cb = new ConfigurationBuilder();
            cb.setOAuthConsumerKey(consumerKey[TokenIndice]);
            cb.setOAuthConsumerSecret(this.consumerSecret[TokenIndice]);
            cb.setOAuthAccessToken(this.token[TokenIndice]);
            cb.setOAuthAccessTokenSecret(this.tokenSecret[TokenIndice]);
            Twitter unauthenticatedTwitter = new TwitterFactory(cb.build()).getInstance();

            for (int numtTweets = contadorBase; numtTweets < contadorBase + 5; numtTweets++) {

                if (((ObjetoBuscar) lista.get(numtTweets)).getUrl().equals("")
                        || ((ObjetoBuscar) lista.get(numtTweets)).getUrl() == null) {

                } else {

                    System.out.println("Usuario:  " + ((ObjetoBuscar) lista.get(numtTweets)).getUrl());

                    String usuariosinArroba = ((ObjetoBuscar) lista.get(numtTweets)).getUrl().replace("@", "");

                    System.out.println("" + usuariosinArroba);

                    try {

                        User usuario = unauthenticatedTwitter.showUser(usuariosinArroba);
                        List<Status> ret = unauthenticatedTwitter.getRetweetsOfMe();
                        List<Status> favoritos = unauthenticatedTwitter.getFavorites();
                        Paging paging = new Paging(1, 1000);
                        ResponseList<Status> statuses = unauthenticatedTwitter.getUserTimeline(usuario.getId(),
                                paging);
                        System.out.println("Followers: " + usuario.getFollowersCount());
                        System.out.println("Yo sigo: " + usuario.getFriendsCount());
                        List<String> listaTweets = new ArrayList();
                        List<Long> ListaRettewts = new ArrayList();
                        List<Integer> ListaFavoritos = new ArrayList();
                        List<Integer> ListaMenciones = new ArrayList();
                        List<Date> ListaFecha = new ArrayList();
                        List<Long> ListaIds = new ArrayList();
                        for (Status sta : statuses) {
                            ListaIds.add(Long.valueOf(sta.getId()));
                            listaTweets.add(sta.getText());
                            ListaRettewts.add(Long.valueOf(Long.parseLong(sta.getRetweetCount() + "")));
                            ListaMenciones.add(Integer.valueOf(sta.getUserMentionEntities().length));
                            ListaFecha.add(sta.getCreatedAt());
                            ListaFavoritos.add(Integer.valueOf(sta.getFavoriteCount()));
                        }
                        for (int i = 0; i < listaTweets.size(); i++) {
                            base.guardarTrackTwitter_Log((Long) ListaIds.get(i),
                                    ((ObjetoBuscar) lista.get(numtTweets)).getUrl(),
                                    (String) listaTweets.get(i), (Date) ListaFecha.get(i),
                                    (Long) ListaRettewts.get(i), ((Integer) ListaFavoritos.get(i)).intValue(),
                                    ((Integer) ListaMenciones.get(i)).intValue());
                        }

                    } catch (Exception e) {
                        System.err.println("Entro al Try por :" + e);
                    }

                    nuevoContadorBase = numtTweets;
                }
            }
            System.out.println("Numero de Contador Base:" + nuevoContadorBase);
            guardarResultados_Twitter(lista, base, nuevoContadorBase + 1, TokenIndice + 1);
        } catch (NumberFormatException e) {
            System.err.println("Fallo por :" + e);
        }
    }
}