我想按位置和语言过滤twitter流。但面临错误。在链接中提到巴基斯坦Twitter流经纬度框
我已经使用位置参数 Passing Longitude and Latitude in Twitter Streaming API of Pakistan
错误: 7924 [Twitter的数据流的消费1建立连接] WARN twitter4j.TwitterStreamImpl - 不与角色接受的参数。 406:在请求中指定无效格式时,由Search API返回。
当一个或多个参数不适合资源时,由Streaming API返回。例如,track参数会在以下情况下引发此错误:
track关键字太长或太短。
指定的边界框无效。
没有为筛选的资源定义谓词,例如,既没有跟踪也没有遵循 定义的参数。
按照用户ID不能被读取。
找不到过滤器参数。预计至少有一个参数:跟踪位置
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"}));
.
请帮我,我错在哪里?
问题寻求帮助调试(“**为什么不是这个代码工作的**?”)必须包括所期望的行为,一个特定的问题或错误的和必要的最短的代码在问题本身**中重现它**。没有**明确问题陈述**的问题对其他读者没有用处。请参见[如何创建最小,完整和可验证示例](http://stackoverflow.com/help/mcve)。 – DavidPostill 2014-08-29 09:02:56
我已经上传部分代码。因为这个代码在Storm中使用。 Storm代码太大。我的问题是,FilterQuery发送错误的位置是无效的。但我提到了位置边界框。你明白我的观点了吗? – 2014-08-29 11:04:09
@IshwarLal是否收到来自巴基斯坦的推文?你在追加数组中添加了什么? – kashifmehmood 2015-01-20 15:27:04