List of usage examples for twitter4j Query setCount
public void setCount(int count)
From source file:wedt.project.MainWindow.java
private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchButtonActionPerformed statusLabel.setText("Trwa wyszukiwanie..."); lockUI();//w w w . j a v a 2 s . co m SwingWorker<List<Status>, Void> worker = new SwingWorker<List<Status>, Void>() { @Override protected List<Status> doInBackground() throws Exception { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("PG0vtiQ73sbKKCfp9JfqyQ") .setOAuthConsumerSecret("ITCkTQiqCh3aVZexXentwnwCJooVpUOcpkIENPKowI") .setOAuthAccessToken("89783194-z0J1KLudg6MFMhhysKmL29zB5wBjxfxWUboAh6lAI") .setOAuthAccessTokenSecret("ytOdt7t8P1OrmAI2ZCRoX30ZC3eLcDSgPY8gOa6FCwQ"); TwitterFactory tf = new TwitterFactory(cb.build()); Twitter twitter = tf.getInstance(); try { Query query = new Query(searchField.getText()); query.setCount(10); query.setLang("en"); if (checkBoxLatest.isSelected() && checkBoxPopular.isSelected()) query.setResultType(Query.ResultType.mixed); else if (checkBoxLatest.isSelected()) query.setResultType(Query.ResultType.recent); else if (checkBoxPopular.isSelected()) query.setResultType(Query.ResultType.popular); QueryResult result = twitter.search(query); return result.getTweets(); } catch (TwitterException e) { statusLabel.setText("Wyszukiwanie nie powiodlo sie"); e.printStackTrace(); //System.out.println("Failed to search tweets: " + te.getMessage()); JOptionPane.showMessageDialog(null, e.getMessage(), "Blad pobierania wynikow wyszukiwania", JOptionPane.INFORMATION_MESSAGE); } return null; } @Override protected void done() { try { List<Status> tweets = get(); listModel = new DefaultListModel(); tweetsList.setModel(listModel); tweets.stream().forEach((tweet) -> { listModel.addElement(tweet.getText()); }); statusLabel.setText("Gotowe"); } catch (Exception ex) { ex.printStackTrace(); statusLabel.setText("Wyszukiwanie nie powiodlo sie"); } unlockUI(); } }; worker.execute(); }
From source file:wise.TwitterUtils.java
public static Query SetQueryString(String place, Date since, Date until) { Query query = new Query("place:" + place + "url:swarmapp.com"); String startDate = new SimpleDateFormat("yyyy-MM-dd").format(since); String endDate = new SimpleDateFormat("yyyy-MM-dd").format(until); query.setCount(100); query.setSince(startDate);//from w w w . java 2 s . com query.setUntil(endDate); query.setSinceId(0); return query; }