本文整理匯總了Java中twitter4j.conf.ConfigurationBuilder.setHttpProxyHost方法的典型用法代碼示例。如果您正苦於以下問題:Java ConfigurationBuilder.setHttpProxyHost方法的具體用法?Java ConfigurationBuilder.setHttpProxyHost怎麽用?Java ConfigurationBuilder.setHttpProxyHost使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類twitter4j.conf.ConfigurationBuilder
的用法示例。
在下文中一共展示了ConfigurationBuilder.setHttpProxyHost方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getConfiguration
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
/**
* Builds a Twitter4J Configuration using the OAuth params.
*
* @return Configuration
*/
public Configuration getConfiguration() {
checkComplete();
ConfigurationBuilder confBuilder = new ConfigurationBuilder();
confBuilder.setOAuthConsumerKey(consumerKey);
confBuilder.setOAuthConsumerSecret(consumerSecret);
confBuilder.setOAuthAccessToken(accessToken);
confBuilder.setOAuthAccessTokenSecret(accessTokenSecret);
if (getHttpProxyHost() != null) {
confBuilder.setHttpProxyHost(getHttpProxyHost());
}
if (getHttpProxyUser() != null) {
confBuilder.setHttpProxyHost(getHttpProxyUser());
}
if (getHttpProxyPassword() != null) {
confBuilder.setHttpProxyHost(getHttpProxyPassword());
}
if (httpProxyPort != null) {
confBuilder.setHttpProxyPort(httpProxyPort);
}
return confBuilder.build();
}
示例2: getTweetsFromQuery
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
private List<TwitterFeature> getTweetsFromQuery(Query query)
throws TwitterException {
List<TwitterFeature> features = new ArrayList<>();
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey(apiKey);
cb.setOAuthConsumerSecret(apiSecret);
cb.setOAuthAccessToken(accessToken);
cb.setOAuthAccessTokenSecret(tokenSecret);
if (proxy) {
cb.setHttpProxyHost(proxyHost);
cb.setHttpProxyPort(proxyPort);
}
if (logger.isDebugEnabled())
logger.debug(query.toString());
Twitter twitter = new TwitterFactory(cb.build()).getInstance();
QueryResult result = twitter.search(query);
boolean loop = true;
while (loop) {
System.out.println(result.getTweets().size() + " tweets in this page");
for (Status status : result.getTweets()) {
System.out.println(status.toString());
TwitterFeature feature = new TwitterFeature(status);
if (feature.getGeom() == null)
continue;
features.add(feature);
}
Query nextQuery = result.nextQuery();
if (nextQuery == null)
loop = false;
else {
result = twitter.search(nextQuery);
}
}
System.out.println(features.size() + " tweets retrieved");
if (logger.isDebugEnabled())
logger.debug(features.size() + " tweets retrieved");
return features;
}
示例3: buildConfiguration
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
private Configuration buildConfiguration() {
final ConfigurationBuilder builder = new ConfigurationBuilder();
builder.setUseSSL(useSsl);
builder.setJSONStoreEnabled(true);
builder.setApplicationOnlyAuthEnabled(true);
if (StringUtils.isNotBlank(httpProxyHost) && httpProxyPort > 0) {
builder.setHttpProxyHost(httpProxyHost);
builder.setHttpProxyPort(httpProxyPort);
}
return builder.build();
}
示例4: tweetRequests
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void tweetRequests(DebugOutputListener out, boolean debug, String consumerKey, String consumerSecret, String accessToken, String accessTokenSecret, String proxyHost, int proxyPort) {
ArrayList<TweetRequest> queueLog = (ArrayList<TweetRequest>) FileUtils.read(LOG_NEXT_TWEET_LIST, new TypeToken<ArrayList<TweetRequest>>() {}.getType());
if (queueLog != null) {
mRequests.addAll(0, queueLog);
}
if (out != null) {
out.onOutput("ツイートキュー數:" + mRequests.size());
}
ArrayList<TweetRequest> nextQueueLog = new ArrayList<TweetRequest>();
while (mRequests.size() > 7) {
nextQueueLog.add(mRequests.remove(7));
}
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.setOAuthConsumerKey(consumerKey);
builder.setOAuthConsumerSecret(consumerSecret);
builder.setOAuthAccessToken(accessToken);
builder.setOAuthAccessTokenSecret(accessTokenSecret);
if (!proxyHost.isEmpty()) {
builder.setHttpProxyHost(proxyHost);
builder.setHttpProxyPort(proxyPort);
}
Twitter twitter = new TwitterFactory(builder.build()).getInstance();
for (TweetRequest req : mRequests) {
for (String str : req.getList()) {
try {
if (out != null) {
out.onOutput("ツイート:" + str);
}
if (!debug) {
twitter.updateStatus(str);
}
} catch (TwitterException e) {
e.printStackTrace();
if (out != null) {
out.onOutput("ツイート失敗");
out.onOutput(e.toString());
}
if (e.getErrorCode() != 187 && e.getErrorCode() != 186) {
nextQueueLog.add(req);
}
break;
}
}
}
if (queueLog == null || queueLog.size() != 0 || nextQueueLog.size() != 0) {
FileUtils.write(nextQueueLog, LOG_NEXT_TWEET_LIST, new TypeToken<ArrayList<TweetRequest>>() {}.getType());
}
}