Получение 6-месячного твиты с определенным хэштегом в Twitter
using this code...i m getting only 7 days tweets from the #india...i want to get atleast six month tweets from the hashtag.. i m trying to get the tweets from particular hashtag and write it into the notepad....guide me to get atleast six month tweets from the hashtag india
Что я уже пробовал:
FileWriter fw=null; BufferedWriter bw=null; fw=new FileWriter("D:\\india.txt"); bw=new BufferedWriter(fw); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true) .setOAuthConsumerKey("xxxx") .setOAuthConsumerSecret("xxxx") .setOAuthAccessToken("xxxx") .setOAuthAccessTokenSecret("xxxx"); Twitter twitter = new TwitterFactory(cb.build()).getInstance(); Query query = new Query("#india"); long lastID = Long.MAX_VALUE; ArrayList<Status> tweets = new ArrayList<Status>(); query.setCount(100); try { QueryResult result = twitter.search(query); tweets.addAll(result.getTweets()); System.out.println("Gathered " + tweets.size() + " tweets"); for (Status t: tweets) if(t.getId() < lastID) lastID = t.getId(); query.setMaxId(lastID-1); for (int i = 0; i < tweets.size(); i++) { Status t = (Status) tweets.get(i); String user = t.getUser().getScreenName(); String msg = t.getText(); Date date =t.getCreatedAt(); bw.write("\n"+i+".USER"+"\n"+"DATE - "+date+"\n"+"USER" +user+"\t"+" wrote"+"\n"+"MSG - "+t.getText()+"\n"+"="); } } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get timeline: " + te.getMessage()); System.exit(-1); } } }