Closed shiwangsimba closed 2 years ago
What do you mean exactly ?
like: setProxy("xxx.xxx.xxx.xxx"); setPort("8080");
There may be some problems with my network. I can open twitter in Google, but the running code will report an error. It says that the connection time out. I found some solutions elsewhere, saying it is a proxy problem
like this.This is the library of twitter 4J. I want to use the function of searching all tweets, but it doesn't have this function, so I replaced your library, but what's more embarrassing is that I can't use the proxy function
Maybe you can set it up directly using your own HttpClient ?
Like TwitterClient twitterClient = new TwitterClient(twitterCredentials, getServiceBuilder(twitterCredentials.getApiKey()));
private ServiceBuilder getServiceBuilder(String apiKey) {
Builder httpBuilder = new Builder()
.addNetworkInterceptor(new CacheInterceptor())
// see if you can add here proxy info
OkHttpHttpClient okHttpClient = new OkHttpHttpClient(new OkHttpHttpClientConfig(httpBuilder));
return new ServiceBuilder(apiKey)
.httpClient(okHttpClient);
}
thank you , According to your prompt, I finally solved the problem like this
but why I can get the data normally with "searchTweets", but the result returned by "searchAllTweets" is null
Maybe because you don't have an authorised account ? Please check the error logs.
Maybe because you don't have an authorised account ? Please check the error logs.
no,There is no error. When I use "searchTweets", the console outputs data, but when I use "searchAllTweets", there is no output, but the program runs normally without error. When I debug at breakpoint, I find that the "data" and other properties of the variable "result" are null
What I don't understand is that the strings I search are the same. Why do I use "searchTweets" and "searchAllTweets" have different results
Because searchAllTweets is only for premium Twitter API accounts, and the time frame is not the same. If you don't have a premium account, you won't be able to use this API. If you check the error logs you will see it.
Because searchAllTweets is only for premium Twitter API accounts, and the time frame is not the same. If you don't have a premium account, you won't be able to use this API. If you check the error logs you will see it.
ok...I see. Thank you for your reply
Can i set proxy?Otherwise, I will always report errors: Connection timed out: connect