本文整理匯總了Java中twitter4j.conf.ConfigurationBuilder.setJSONStoreEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Java ConfigurationBuilder.setJSONStoreEnabled方法的具體用法?Java ConfigurationBuilder.setJSONStoreEnabled怎麽用?Java ConfigurationBuilder.setJSONStoreEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類twitter4j.conf.ConfigurationBuilder
的用法示例。
在下文中一共展示了ConfigurationBuilder.setJSONStoreEnabled方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTwitter
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
private Twitter getTwitter() {
TwitterCredentials creds = readCredentials();
if (creds.getConsumerKey() == null) {
throw new RuntimeException("Incorrect Twitter client configuration: Consumer key is null");
}
if (creds.getConsumerSecret() == null) {
throw new RuntimeException("Incorrect Twitter client configuration: Consumer secret is null");
}
if (creds.getAccessSecret() == null) {
throw new RuntimeException("Incorrect Twitter client configuration: Access secret is null");
}
if (creds.getAccessToken() == null) {
throw new RuntimeException("Incorrect Twitter client configuration: Access token is null");
}
ConfigurationBuilder twitterConfig = new ConfigurationBuilder();
twitterConfig.setOAuthConsumerKey(creds.getConsumerKey());
twitterConfig.setOAuthConsumerSecret(creds.getConsumerSecret());
twitterConfig.setOAuthAccessToken(creds.getAccessToken());
twitterConfig.setOAuthAccessTokenSecret(creds.getAccessSecret());
twitterConfig.setJSONStoreEnabled(true);
return new TwitterFactory(twitterConfig.build()).getInstance();
}
示例2: twitterStream
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
@Bean
public TwitterStream twitterStream() {
String consumerKey = environment.getRequiredProperty("consumerKey");
String consumerSecret = environment.getRequiredProperty("consumerSecret");
String accessToken = environment.getRequiredProperty("accessToken");
String accessTokenSecret = environment.getRequiredProperty("accessTokenSecret");
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey(consumerKey);
cb.setOAuthConsumerSecret(consumerSecret);
cb.setOAuthAccessToken(accessToken);
cb.setOAuthAccessTokenSecret(accessTokenSecret);
cb.setJSONStoreEnabled(true);
cb.setIncludeEntitiesEnabled(true);
return new TwitterStreamFactory(cb.build()).getInstance();
}
示例3: open
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
public void open(Map conf, TopologyContext context,
SpoutOutputCollector collector) {
queue = new LinkedBlockingQueue<String>(1000);
this.collector = collector;
StatusListener listener = new StatusListener() {
public void onStatus(Status status) {
queue.offer(TwitterObjectFactory.getRawJSON(status));
}
public void onDeletionNotice(StatusDeletionNotice sdn) { }
public void onTrackLimitationNotice(int i) { }
public void onScrubGeo(long l, long l1) { }
public void onStallWarning(StallWarning stallWarning) { }
public void onException(Exception e) { }
};
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setJSONStoreEnabled(true);
TwitterStreamFactory factory = new TwitterStreamFactory(cb.build());
twitterStream = factory.getInstance();
twitterStream.addListener(listener);
twitterStream.filter(new FilterQuery().language("en").track("trump"));
}
示例4: connectToTwitterAPI
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
/**
* Creates the connection to Twitter API.
* @return Twitter object for the current connection
*/
public static Twitter connectToTwitterAPI() {
ConfigurationBuilder cb = new ConfigurationBuilder();
/*please fill in your credentials*/
cb.setDebugEnabled(true).setOAuthConsumerKey("CONSUMER_KEY")
.setOAuthConsumerSecret("CONSUMER_SECRET")
.setOAuthAccessToken("ACCESS_TOKEN")
.setOAuthAccessTokenSecret("ACCESS_TOKEN_SECRET");
cb.setJSONStoreEnabled(true);
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
return twitter;
}
示例5: init
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
/**
* Initializes this gateway
*/
@Override
@SuppressWarnings("rawtypes")
public void init(final GatewayEngine engine, final String id, final String cfcPath, final Map config) throws IOException
{
try
{
this.argType = ArgumentType.fromConfigValue((String) config.get(ARGUMENT_TYPE));
final ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey((String) config.get(OAUTH_CONSUMER_KEY));
cb.setOAuthConsumerSecret((String) config.get(OAUTH_CONSUMER_SECRET));
cb.setOAuthAccessToken((String) config.get(OAUTH_ACCESS_TOKEN));
cb.setOAuthAccessTokenSecret((String) config.get(OAUTH_ACCESS_SECRET));
cb.setUserStreamRepliesAllEnabled(Boolean.valueOf((String) config.get(ALL_REPLIES)));
cb.setJSONStoreEnabled(ArgumentType.JSON.equals(this.argType));
super.init(engine, id, new TwitterUserStream(this, cb.build()));
}
catch (Throwable t)
{
final IOException ex = new IOException("Unable to initialize gateway", t);
this.onException(ex);
throw ex;
}
}
示例6: configure
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
@Override
public void configure(Properties props) {
ProducerConfig config = new ProducerConfig(props);
producer = new Producer<String, String>(config);
// The necessary authentication keys to connect to twitter API v1.1
String consumerKey = props.getProperty(TwitterProducerConstants.CONSUMER_KEY_KEY);
String consumerSecret = props.getProperty(TwitterProducerConstants.CONSUMER_SECRET_KEY);
String accessToken = props.getProperty(TwitterProducerConstants.ACCESS_TOKEN_KEY);
String accessTokenSecret = props.getProperty(TwitterProducerConstants.ACCESS_TOKEN_SECRET_KEY);
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey(consumerKey);
cb.setOAuthConsumerSecret(consumerSecret);
cb.setOAuthAccessToken(accessToken);
cb.setOAuthAccessTokenSecret(accessTokenSecret);
cb.setJSONStoreEnabled(true);
cb.setIncludeEntitiesEnabled(true);
twitterStream = new TwitterStreamFactory(cb.build()).getInstance();
}
示例7: streamTweets
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
public void streamTweets() {
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey(oAuthConsumerKey).setOAuthConsumerSecret(oAuthConsumerSecret)
.setOAuthAccessToken(oAuthAccessToken).setOAuthAccessTokenSecret(oAuthAccessTokenSecret);
cb.setJSONStoreEnabled(true);
TwitterStream twitterStream = new TwitterStreamFactory(cb.build()).getInstance();
twitterStream.addListener(listener);
FilterQuery filterQ = new FilterQuery();
filterQ.language(languages);
filterQ.track(searchKeywords);
twitterStream.filter(filterQ);
}
示例8: configure
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
/**
* The initialization method for the Source. The context contains all the
* Flume configuration info, and can be used to retrieve any configuration
* values necessary to set up the Source.
*/
@Override
public void configure(Context context) {
consumerKey = context.getString(TwitterSourceConstants.CONSUMER_KEY_KEY);
consumerSecret = context.getString(TwitterSourceConstants.CONSUMER_SECRET_KEY);
accessToken = context.getString(TwitterSourceConstants.ACCESS_TOKEN_KEY);
accessTokenSecret = context.getString(TwitterSourceConstants.ACCESS_TOKEN_SECRET_KEY);
keywords = csvToArray(context.getString(TwitterSourceConstants.KEYWORDS_KEY, ""));
langs = csvToArray(context.getString(TwitterSourceConstants.LANGS_KEY, ""));
follow = csvToArrayLong(context.getString(TwitterSourceConstants.FOLLOWS_KEY, ""));
processLocations(context.getString(TwitterSourceConstants.LOCATIONS_KEY, ""));
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey(consumerKey);
cb.setOAuthConsumerSecret(consumerSecret);
cb.setOAuthAccessToken(accessToken);
cb.setOAuthAccessTokenSecret(accessTokenSecret);
cb.setJSONStoreEnabled(true); // important to convert status to raw json format
cb.setIncludeEntitiesEnabled(true);
twitterStream = new TwitterStreamFactory(cb.build()).getInstance();
if (sourceCounter == null) {
sourceCounter = new TwitterSourceCounter(getName());
}
}
示例9: main
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
public static void main(String [] args){
/**
* To run this sample, edit twitter4j.properties file with your API Keys.
*/
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setJSONStoreEnabled(true);
StatusListener listener = new StatusListener(){
public void onStatus(Status status) {
System.out.println(TwitterObjectFactory.getRawJSON(status));
}
public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {}
public void onTrackLimitationNotice(int numberOfLimitedStatuses) {}
public void onScrubGeo(long l, long l1) {}
public void onStallWarning(StallWarning stallWarning) {}
public void onException(Exception ex) {
ex.printStackTrace();
}
};
TwitterStreamFactory tsf = new TwitterStreamFactory(cb.build());
TwitterStream twStream = tsf.getInstance();
twStream.addListener(listener);
twStream.sample();
}
示例10: setupConfigurationBuilder
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
@Override
protected ConfigurationBuilder setupConfigurationBuilder()
{
ConfigurationBuilder cb = super.setupConfigurationBuilder();
cb.setJSONStoreEnabled(true);
return cb;
}
示例11: makeConfiguration
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
private static Configuration makeConfiguration(TwitterAPIToken token) {
final ConfigurationBuilder cb = new ConfigurationBuilder()
.setOAuthConsumerKey(token.consumerKey)
.setOAuthConsumerSecret(token.consumerSecret)
.setOAuthAccessToken(token.accessToken)
.setOAuthAccessTokenSecret(token.accessSecret);
cb.setJSONStoreEnabled(true);
return cb.build();
}
示例12: makeConfiguration
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
protected Configuration makeConfiguration(TwitterAPIToken token) {
final ConfigurationBuilder cb = new ConfigurationBuilder()
.setOAuthConsumerKey(token.consumerKey)
.setOAuthConsumerSecret(token.consumerSecret)
.setOAuthAccessToken(token.accessToken)
.setOAuthAccessTokenSecret(token.accessSecret);
cb.setJSONStoreEnabled(true);
return cb.build();
}
示例13: 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();
}
示例14: TweetsIterator
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
public TweetsIterator(final Query query) {
this.nextQuery = query;
final ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setJSONStoreEnabled(true);
twitter = new TwitterFactory(cb.build()).getInstance();
}
示例15: configure
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
@Override
public void configure(Context context) {
consumerKey = context.getString("consumerKey");
consumerSecret = context.getString("consumerSecret");
accessToken = context.getString("accessToken");
accessTokenSecret = context.getString("accessTokenSecret");
LOGGER.info("Consumer Key: '" + consumerKey + "'");
LOGGER.info("Consumer Secret: '" + consumerSecret + "'");
LOGGER.info("Access Token: '" + accessToken + "'");
LOGGER.info("Access Token Secret: '" + accessTokenSecret + "'");
String southWestLatitude;
String southWestLongitude;
String northEastLatitude;
String northEastLongitude;
String keywords;
//Top-left coordinate
southWestLatitude = context.getString("south_west_latitude");
southWestLongitude = context.getString("south_west_longitude");
LOGGER.info("South-West coordinate: '" + southWestLatitude + " " + southWestLongitude + "'");
//Bottom-right coordinate
northEastLatitude = context.getString("north_east_latitude");
northEastLongitude = context.getString("north_east_longitude");
LOGGER.info("North-East coordinate: '" + northEastLatitude + " " + northEastLongitude + "'");
keywords = context.getString("keywords");
LOGGER.info("Keywords: '" + keywords + "'");
if (southWestLatitude != null && southWestLongitude != null
&& northEastLatitude != null && northEastLongitude != null) {
double latitude1 = Double.parseDouble(southWestLatitude);
double longitude1 = Double.parseDouble(southWestLongitude);
double latitude2 = Double.parseDouble(northEastLatitude);
double longitude2 = Double.parseDouble(northEastLongitude);
boundingBox = new double[][]{
new double[]{longitude1, latitude1}, // south-west
new double[]{longitude2, latitude2} // north-east
};
LOGGER.info("Coordinates: '" + boundingBox[0][0] + " " + boundingBox[0][1]
+ " " + boundingBox[1][0] + " " + boundingBox[1][1] + "'");
haveFilters = true;
haveCoordinateFilter = true;
}
if (keywords != null) {
if (keywords.trim().length() != 0) {
splitKeywords = keywords.split(",");
for (int i = 0; i < splitKeywords.length; i++) {
splitKeywords[i] = splitKeywords[i].trim();
}
LOGGER.info("keywords: {}", Arrays.toString(splitKeywords));
haveFilters = true;
haveKeywordFilter = true;
}
}
maxBatchSize = context.getInteger("maxBatchSize", maxBatchSize);
maxBatchDurationMillis = context.getInteger("maxBatchDurationMillis",
maxBatchDurationMillis);
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true);
cb.setOAuthConsumerKey(consumerKey);
cb.setOAuthConsumerSecret(consumerSecret);
cb.setOAuthAccessToken(accessToken);
cb.setOAuthAccessTokenSecret(accessTokenSecret);
cb.setJSONStoreEnabled(true);
twitterStream = new TwitterStreamFactory(cb.build()).getInstance();
}