I want to filter twitter streams by location and language. But facing error.
I have used location parameter mentioned in link Passing Longitude and Latitude in Twitter Streaming API of Pakistan
Error : 7924 [Twitter Stream consumer-1[Establishing connection]] WARN twitter4j.TwitterStreamImpl - Parameter not accepted with the role. 406:Returned by the Search API when an invalid format is specified in the request.
Returned by the Streaming API when one or more of the parameters are not suitable for the resource. The track parameter, for example, would throw this error if:
The track keyword is too long or too short.
The bounding box specified is invalid.
No predicates defined for filtered resource, for example, neither track nor follow parameter defined.
Follow userid cannot be read.
No filter parameters found. Expect at least one parameter: follow track locations
LinkedBlockingQueue<Status> queue = new LinkedBlockingQueue<Status>(1000);
SpoutOutputCollector _collector = collector;
StatusListener listener = new StatusListener() {
@Override
public void onStatus(Status status) {
System.out.println(status.getLang());
System.out.println(status.getPlace());
System.out.print(status.getText());
}
@Override
public void onDeletionNotice(StatusDeletionNotice sdn) {
}
@Override
public void onTrackLimitationNotice(int i) {
}
@Override
public void onScrubGeo(long l, long l1) {
}
@Override
public void onException(Exception e) {
}
@Override
public void onStallWarning(StallWarning arg0) {
// TODO Auto-generated method stub
}
};
TwitterStreamFactory fact = new TwitterStreamFactory(new ConfigurationBuilder().setUser(_username).setPassword(_pwd).build());
TwitterStream _twitterStream = fact.getInstance();
_twitterStream.addListener(listener);
ArrayList<Long> follow = new ArrayList<Long>();
ArrayList<String> track = new ArrayList<String>();
long[] followArray = new long[follow.size()];
String[] trackArray = track.toArray(new String[track.size()]);
/**
* Upper/northern latitude that marks the
* upper bounds of the geographical area
* for which tweets need to be analysed.
*/
double northLatitude = 35.2;
/**
* Lower/southern latitude. Marks the lower bound.
*/
double southLatitude = 25.2;
/**
* Eastern/left longitude. Marks the left-side bounds.
*/
double eastLongitude = 62.9;
/**
* Western/right longitude. Marks the right-side bounds.
*/
double westLongitude = 73.3;
double bb[][] = {{eastLongitude, southLatitude}
,{westLongitude, northLatitude}};
_twitterStream.filter(new FilterQuery(0, followArray,trackArray,bb,new String[]{"en-US"}));
.
Please help me where am i wrong?