我有一个特定的要求,我想根据以下参数收集所有推文
1)我使用搜索 API,例如我想搜索“Iphone6”
2)区域明智,即如果我根据城市指定纬度和经度我得到结果,是否可以在国家/地区明智地获取所有结果(如代码中当我指定印度的纬度和经度时它不起作用!)
3)我应该在什么时间间隔运行我的应用程序,这样我才能获得新更新的推文,而不会获得以前获取的推文。
This is the code that I have written
public final class twitterdate {
public static void main(String[] args)throws Exception {
double res;
double lat,lon;
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey("MyKEY")
.setOAuthConsumerSecret("MySecret")
.setOAuthAccessToken("MyAccesstoken")
.setOAuthAccessTokenSecret("MyTokenSecret").setHttpConnectionTimeout(100000);
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
lat=18.9750; // THis works , but it doenst work when I specify latitude and longitude of India
lon=72.8258;
res=1;
try {
QueryResult result=twitter.search(new Query("iphone").since("2014-11-19").until("2014-11-22").geoCode(new GeoLocation(lat, lon), res,"1mi"));
// Since and untill doesnt work as expected sometimes it fetches the date tweets specified on "since" method sometimes fetches the tweets specified on the date of until method
// Also since and until doesnt work when i specify a time stamp.
List<Status> qrTweets = result.getTweets();
System.out.println("hi");
for (Status tweet : qrTweets )
{
System.out.println( tweet.getId() + " " + "@" + tweet.getUser().getScreenName() + " : " + tweet.getText() + " :::" + tweet.getCreatedAt() );
}
} catch (TwitterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
如果有人可以帮助我满足我的要求,我会非常感激,因为我已经用谷歌搜索了很多但找不到任何合适的解决方案。提前致谢 !