我正在尝试使用具有单一身份验证的不同 TwitterStream 对象执行不同的线程:
public class Support {
private static final String accessToken = "xxxxxxx";
private static final String accessTokenSecret = "xxxxxxx";
public static final AccessToken token = new AccessToken(accessToken, accessTokenSecret);
private static final String consumerKey = "xxxxxxx";
private static final String consumerSecret = "xxxxxxx";
private static final Configuration conf = new ConfigurationBuilder().setOAuthConsumerKey(consumerKey).setOAuthConsumerSecret(consumerSecret).build();
public static TwitterStreamFactory factory = new TwitterStreamFactory(conf);
}
在我做的每个线程中:
public MyThread1(){
this.twitterStream = Support.factory.getInstance(Support.token);
}
public void run(){
StatusListener listener = ... ;
twitterStream.addListener(listener);
FilterQuery fq = new FilterQuery();
fq.track(new String[]{"hashtag1","hashtag2"});
twitterStream.filter(fq);
}
public MyThread2(){
this.twitterStream = Support.factory.getInstance(Support.token);
}
public void run(){
StatusListener listener = ... ;
twitterStream.addListener(listener);
FilterQuery fq = new FilterQuery();
fq.track(new String[]{"hashtag3","hashtag4"});
twitterStream.filter(fq);
}
但它给了我身份验证错误.. 同一身份验证的多个请求。我该如何解决?