當前位置: 首頁>>代碼示例>>Java>>正文


Java ConfigurationBuilder.setJSONStoreEnabled方法代碼示例

本文整理匯總了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();
}
 
開發者ID:arun-gupta,項目名稱:tweet-analysis,代碼行數:23,代碼來源:TwitterFeed.java

示例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();
}
 
開發者ID:malejpavouk,項目名稱:kafka-twitter-producer,代碼行數:18,代碼來源:TwitterProducerApp.java

示例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"));
}
 
開發者ID:mayconbordin,項目名稱:erad2016-streamprocessing,代碼行數:26,代碼來源:TwitterSpout.java

示例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;
}
 
開發者ID:MKLab-ITI,項目名稱:image-verification-corpus,代碼行數:21,代碼來源:DatasetFeaturesExtractor.java

示例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;
  }
}
 
開發者ID:jbvanzuylen,項目名稱:cf-twitter-gateway,代碼行數:27,代碼來源:RailoTwitterUserStreamGateway.java

示例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();
}
 
開發者ID:Sentaware,項目名稱:kafka-producers,代碼行數:22,代碼來源:TwitterProducer.java

示例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);
	}
 
開發者ID:shubhamsharma04,項目名稱:jsonTweetDownload,代碼行數:14,代碼來源:TwitterStreamingService.java

示例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());
	}
}
 
開發者ID:mmartsen,項目名稱:flume-tools,代碼行數:32,代碼來源:TwitterSource.java

示例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();
    }
 
開發者ID:gasparms,項目名稱:sinfonier-dev-tool,代碼行數:30,代碼來源:GetTweet.java

示例10: setupConfigurationBuilder

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
@Override
protected ConfigurationBuilder setupConfigurationBuilder()
{
  ConfigurationBuilder cb = super.setupConfigurationBuilder();
  cb.setJSONStoreEnabled(true);
  return cb;
}
 
開發者ID:tweise,項目名稱:apex-samples,代碼行數:8,代碼來源:TwitterIngestApp.java

示例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();
}
 
開發者ID:openimaj,項目名稱:openimaj,代碼行數:11,代碼來源:Twitter4jUtil.java

示例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();
}
 
開發者ID:openimaj,項目名稱:openimaj,代碼行數:11,代碼來源:AbstractTwitterSearchDataset.java

示例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();
}
 
開發者ID:Adobe-Consulting-Services,項目名稱:acs-aem-commons,代碼行數:12,代碼來源:TwitterAdapterFactory.java

示例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();
}
 
開發者ID:Zuehlke,項目名稱:SHMACK,代碼行數:7,代碼來源:TweetsIterator.java

示例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();

}
 
開發者ID:telefonicaid,項目名稱:fiware-cygnus,代碼行數:79,代碼來源:TwitterSource.java


注:本文中的twitter4j.conf.ConfigurationBuilder.setJSONStoreEnabled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。