当前位置: 首页>>代码示例>>Java>>正文


Java StatusesFilterEndpoint类代码示例

本文整理汇总了Java中com.twitter.hbc.core.endpoint.StatusesFilterEndpoint的典型用法代码示例。如果您正苦于以下问题:Java StatusesFilterEndpoint类的具体用法?Java StatusesFilterEndpoint怎么用?Java StatusesFilterEndpoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StatusesFilterEndpoint类属于com.twitter.hbc.core.endpoint包,在下文中一共展示了StatusesFilterEndpoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureStreamClient

import com.twitter.hbc.core.endpoint.StatusesFilterEndpoint; //导入依赖的package包/类
private static BasicClient configureStreamClient(BlockingQueue<String> msgQueue, String twitterKeys, List<Long> userIds, List<String> terms) {
    Hosts hosts = new HttpHosts(Constants.STREAM_HOST);
    StatusesFilterEndpoint endpoint = new StatusesFilterEndpoint()
            .followings(userIds)
            .trackTerms(terms);
    endpoint.stallWarnings(false);

    String[] keys = twitterKeys.split(":");
    Authentication auth = new OAuth1(keys[0], keys[1], keys[2], keys[3]);

    ClientBuilder builder = new ClientBuilder()
            .name("Neo4j-Twitter-Stream")
            .hosts(hosts)
            .authentication(auth)
            .endpoint(endpoint)
            .processor(new StringDelimitedProcessor(msgQueue));

    return builder.build();
}
 
开发者ID:neo4j-examples,项目名称:neo4j-twitter-stream,代码行数:20,代码来源:TwitterStreamProcessor.java

示例2: getTwitterClient

import com.twitter.hbc.core.endpoint.StatusesFilterEndpoint; //导入依赖的package包/类
private  Client getTwitterClient(Properties props, BlockingQueue<String> messageQueue) {

        String clientName = props.getProperty("clientName");
        String consumerKey = props.getProperty("consumerKey");
        String consumerSecret = props.getProperty("consumerSecret");
        String token = props.getProperty("token");
        String tokenSecret = props.getProperty("tokenSecret");
        List<String> searchTerms = Arrays.asList(props.getProperty("searchTerms").split(","));

        Authentication authentication = new OAuth1(consumerKey,consumerSecret,token,tokenSecret);
        Hosts hosebirdHosts = new HttpHosts(Constants.STREAM_HOST);
        StatusesFilterEndpoint hosebirdEndpoint = new StatusesFilterEndpoint();

        hosebirdEndpoint.trackTerms(searchTerms);

        ClientBuilder clientBuilder = new ClientBuilder();
        clientBuilder.name(clientName)
                .hosts(hosebirdHosts)
                .authentication(authentication)
                .endpoint(hosebirdEndpoint)
                .processor(new StringDelimitedProcessor(messageQueue));

          return clientBuilder.build();

    }
 
开发者ID:bbejeck,项目名称:kafka-streams,代码行数:26,代码来源:TwitterDataSource.java

示例3: initialize

import com.twitter.hbc.core.endpoint.StatusesFilterEndpoint; //导入依赖的package包/类
@Override
protected void initialize() throws InitializationException {
	// Initialize endpoint
	this.endpoint = new StatusesFilterEndpoint();
			
	// Initialize queues
	this.queue = new LinkedBlockingQueue<String>(10000);
			
	// Set keywords
	this.endpoint.trackTerms(terms);
		    
    // Create a new BasicClient. By default gzip is enabled.
    this.client = new ClientBuilder()
      .hosts(Constants.STREAM_HOST)
      .endpoint(endpoint)
      .authentication(auth)
      .processor(new StringDelimitedProcessor(queue))
      .build();
}
 
开发者ID:DaniUPC,项目名称:near-image-replica-detection,代码行数:20,代码来源:TwitterProvider.java

示例4: setupHosebirdClient

import com.twitter.hbc.core.endpoint.StatusesFilterEndpoint; //导入依赖的package包/类
public static void setupHosebirdClient() {
       /** Declare the host you want to connect to, the endpoint, and authentication (basic auth or oauth) */
	Hosts hosebirdHosts = new HttpHosts(Constants.STREAM_HOST);
	StatusesFilterEndpoint endpoint = new StatusesFilterEndpoint();

       // Optional: set up some followings and track terms
	List<Long> followings = Lists.newArrayList(1234L, 566788L);
	List<String> terms = Lists.newArrayList("twitter", "api");
	endpoint.followings(followings);
	endpoint.trackTerms(terms);

	Authentication hosebirdAuth = new OAuth1(
       		Helper.properties().getProperty("consumerKey"),
       		Helper.properties().getProperty("consumerSecret"),
       		Helper.properties().getProperty("token"),
       		Helper.properties().getProperty("secret"));

       ClientBuilder builder = new ClientBuilder()
        .name("Hosebird-Client-01")		// optional: mainly for the logs
        .hosts(hosebirdHosts)
        .authentication(hosebirdAuth)
        .endpoint(endpoint)
        .processor(new StringDelimitedProcessor(msgQueue));

	hosebirdClient = builder.build();
}
 
开发者ID:twitterdev,项目名称:twttr-kinesis,代码行数:27,代码来源:TweetCollector.java

示例5: initializeConnection

import com.twitter.hbc.core.endpoint.StatusesFilterEndpoint; //导入依赖的package包/类
@Override
protected void initializeConnection() {
    if (LOG.isInfoEnabled()) {
        LOG.info("Initializing Twitter Streaming API connection");
    }

    this.queue = new LinkedBlockingQueue(this.queueSize);
    StatusesFilterEndpoint endpoint = new StatusesFilterEndpoint(false)
            .locations(Arrays.asList(
                            new Location(
                                    // europa: -32.0 34.0 40.0 75.0
                                    new Location.Coordinate(-32.0, 34.0), // south west
                                    new Location.Coordinate(40.0, 75.0))
                     //       new Location(
                     //               // north america: -168.48633, 13.23995 -50.36133, 72.76406
                     //               new Location.Coordinate(-168.48633, 13.23995), // south west
                     //               new Location.Coordinate(-50.36133, 72.76406))
                    )
            );
    endpoint.stallWarnings(false);
    OAuth1 auth = this.authenticate();

    this.initializeClient(endpoint, auth);
    if (LOG.isInfoEnabled()) {
        LOG.info("Twitter Streaming API connection established successfully");
    }

}
 
开发者ID:IIDP,项目名称:OSTMap,代码行数:29,代码来源:GeoTwitterSource.java

示例6: startFiltering

import com.twitter.hbc.core.endpoint.StatusesFilterEndpoint; //导入依赖的package包/类
public void startFiltering() {

		List<Job> jobs = jobRepository.findAll();
		log.info("There are " + jobs.size() + " jobs in the database.");

		if (jobs.size() == 0) {
			log.error("No jobs found at the database. Please define some jobs first.");
			return;
		}

		BlockingQueue<String> queue = new LinkedBlockingQueue<String>(10000);

		StatusesFilterEndpoint endpoint = new StatusesFilterEndpoint();
		List<String> keywords = new ArrayList<>();
		for (Job j : jobs) {
			keywords.addAll(j.getKeywords());
		}
		endpoint.trackTerms(keywords);

		Authentication auth = new OAuth1(consumerKey, consumerSecret, accessToken, accessSecret);

		this.client = new ClientBuilder().hosts(Constants.STREAM_HOST).endpoint(endpoint).authentication(auth)
				.processor(new StringDelimitedProcessor(queue)).build();

		int numProcessingThreads = 4;
		ExecutorService service = Executors.newFixedThreadPool(numProcessingThreads);

		List<StatusListener> listeners = new ArrayList<>();
		listeners.add(statusStreamHandlerImpl.createListener());

		Twitter4jStatusClient t4jClient = new Twitter4jStatusClient(client, queue, listeners, service);

		t4jClient.connect();
		for (int threads = 0; threads < numProcessingThreads; threads++) {
			t4jClient.process();
		}

	}
 
开发者ID:PySualk,项目名称:TwitterPictureGatherer,代码行数:39,代码来源:CollectorService.java

示例7: start

import com.twitter.hbc.core.endpoint.StatusesFilterEndpoint; //导入依赖的package包/类
@Override
public TwitterAggregator start(final String... keywords) {
    final BlockingQueue<String> queue = new LinkedBlockingQueue<>(10000);

    final Authentication auth = new OAuth1(
            consumerKey,
            consumerSecret,
            token,
            tokenSecret);

    // Create a new BasicClient. By default gzip is enabled.
    final ClientBuilder builder = new ClientBuilder()
            .hosts(Constants.STREAM_HOST)
            .endpoint(new StatusesFilterEndpoint().trackTerms(Lists.newArrayList(keywords)))
            .authentication(auth)
            .processor(new StringDelimitedProcessor(queue));

    // Wrap our BasicClient with the twitter4j client
    client = new Twitter4jStatusClient(
            builder.build(),
            queue,
            Collections.singletonList(new TwitterMessageListener()),
            C1Services.getInstance().getExecutorService());

    client.connect();
    client.process();

    return this;
}
 
开发者ID:martinjmares,项目名称:javaone2015-cloudone,代码行数:30,代码来源:TwitterAggregator.java

示例8: configEndpoint

import com.twitter.hbc.core.endpoint.StatusesFilterEndpoint; //导入依赖的package包/类
public  void configEndpoint(StatusesFilterEndpoint endpoint) {
    LOG.info("-------------------------------------") ;
    LOG.info("-------------------------------------") ;
    LOG.info("BAD CONFIG END POINT");
    LOG.info("-------------------------------------") ;
    LOG.info("-------------------------------------") ;

}
 
开发者ID:LaurentTardif,项目名称:AgileGrenoble2015,代码行数:9,代码来源:TwitterStreamSource.java

示例9: subscribe

import com.twitter.hbc.core.endpoint.StatusesFilterEndpoint; //导入依赖的package包/类
public void subscribe(final StatusStreamHandler listener, String... terms) {
	/**
	 * Set up your blocking queues: Be sure to size these properly based on
	 * expected TPS of your stream
	 */
	BlockingQueue<String> msgQueue = new LinkedBlockingQueue<String>(100000);
	BlockingQueue<Event> eventQueue = new LinkedBlockingQueue<Event>(1000);

	/**
	 * Declare the host you want to connect to, the endpoint, and
	 * authentication (basic auth or oauth)
	 */
	Hosts hosebirdHosts = new HttpHosts(Constants.STREAM_HOST);
	StatusesFilterEndpoint hosebirdEndpoint = new StatusesFilterEndpoint();
	hosebirdEndpoint.trackTerms(Lists.newArrayList(terms));

	Authentication hosebirdAuth = oAuth();

	ClientBuilder builder = new ClientBuilder().name("Hosebird-Client-01")
			// optional: mainly for the logs
			.hosts(hosebirdHosts).authentication(hosebirdAuth).endpoint(hosebirdEndpoint)
			.processor(new StringDelimitedProcessor(msgQueue)).eventMessageQueue(eventQueue);
	Client client = builder.build();

	final ExecutorService executorService = Executors.newFixedThreadPool(1);
	final Twitter4jStatusClient t4jClient = new Twitter4jStatusClient(client, msgQueue,
			Lists.newArrayList(listener), executorService);
	t4jClient.connect();

	// Call this once for every thread you want to spin off for processing
	// the raw messages.
	// This should be called at least once.
	t4jClient.process(); // required to start processing the messages
}
 
开发者ID:cyriux,项目名称:hexagonal-sentimental,代码行数:35,代码来源:TwitterStream.java

示例10: start

import com.twitter.hbc.core.endpoint.StatusesFilterEndpoint; //导入依赖的package包/类
public void start(String hashtag) {
    BlockingQueue<String> queue = new LinkedBlockingQueue<>(10000);
    StatusesSampleEndpoint endpoint = new StatusesSampleEndpoint();
    endpoint.stallWarnings(false);
    StatusesFilterEndpoint filterEndpoint = new StatusesFilterEndpoint();
    List<String> terms = Lists.newArrayList(hashtag);
    filterEndpoint.trackTerms(terms);

    String consumerKey = System.getProperty("twitter.consumerKey", "");
    String consumerSecret = System.getProperty("twitter.consumerSecret", "");
    String token = System.getProperty("twitter.token", "");
    String tokenSecret = System.getProperty("twitter.tokenSecret", "");

    Authentication auth = new OAuth1(consumerKey,consumerSecret,token,tokenSecret);

    client = new ClientBuilder()
            .name("JDG #" + hashtag + " client")
            .hosts(Constants.STREAM_HOST)
            .endpoint(filterEndpoint)
            .authentication(auth)
            .processor(new StringDelimitedProcessor(queue))
            .build();

    TwitterReader reader = new TwitterReader(client, queue, cache, timeout);
    executor = Executors.newSingleThreadExecutor();
    executor.execute(reader);

}
 
开发者ID:redhat-italy,项目名称:jdg-quickstarts,代码行数:29,代码来源:TwitterService.java

示例11: collect

import com.twitter.hbc.core.endpoint.StatusesFilterEndpoint; //导入依赖的package包/类
public void collect() throws IOException {

        final BlockingQueue<String> queue = new LinkedBlockingQueue<>(QUEUE_SIZE);
        final StatusesFilterEndpoint endpoint = new StatusesFilterEndpoint();

        // Set location to collect on
        endpoint.locations(Lists.newArrayList(COLLECTION_LOCATION));

        // add some track terms with this code:
        // endpoint.trackTerms(Lists.newArrayList("twitterapi", "#yolo"));

        final Authentication auth = new OAuth1(consumerKey, consumerSecret, token, secret);

        // Create a new BasicClient. By default gzip is enabled.
        final Client client = new ClientBuilder()
                .hosts(Constants.STREAM_HOST)
                .endpoint(endpoint)
                .authentication(auth)
                .processor(new StringDelimitedProcessor(queue))
                .build();

        // Establish a connection
        client.connect();

        while (!client.isDone()) {
            writeTweetsToFile(getFileToWrite(), queue);
        }

        client.stop();
        log.info("Client stopped, restart needed");
    }
 
开发者ID:geomesa,项目名称:geomesa-twitter,代码行数:32,代码来源:TwitterStreamCollector.java

示例12: activate

import com.twitter.hbc.core.endpoint.StatusesFilterEndpoint; //导入依赖的package包/类
public void activate()
{
    synchronized (_pauseSyncObject)
    {
        try
        {
            _tweetQueue = new LinkedBlockingQueue<String>(TWEETQUEUESIZE);

            StatusesFilterEndpoint endpoint = new StatusesFilterEndpoint();
            endpoint.trackTerms(Lists.newArrayList(_trackTerm));

            Authentication authentication = new OAuth1(_consumerKey, _consumerSecret, _token, _tokenSecret);

            ClientBuilder twitterClientBuilder = new ClientBuilder();
            twitterClientBuilder.name("DataBrokerClient");
            twitterClientBuilder.hosts(Constants.STREAM_HOST);
            twitterClientBuilder.endpoint(endpoint);
            twitterClientBuilder.authentication(authentication);
            twitterClientBuilder.processor(new StringDelimitedProcessor(_tweetQueue));

            _twitterClient = twitterClientBuilder.build();
            _twitterClient.connect();
        }
        catch (Throwable throwable)
        {
            logger.log(Level.WARNING, "TwitterDataSource: Configuring problem \"" + _name + "\"", throwable);
            _twitterClient = null;
            _tweetQueue    = null;
        }

        _fetch = true;
        _pauseSyncObject.notify();
    }
}
 
开发者ID:arjuna-technologies,项目名称:Twitter_DataBroker_PlugIn,代码行数:35,代码来源:TwitterDataSource.java

示例13: run

import com.twitter.hbc.core.endpoint.StatusesFilterEndpoint; //导入依赖的package包/类
public static void run(String consumerKey, String consumerSecret, String token, String secret) throws InterruptedException {
  BlockingQueue<String> queue = new LinkedBlockingQueue<String>(10000);
  StatusesFilterEndpoint endpoint = new StatusesFilterEndpoint();
  // add some track terms
  endpoint.trackTerms(Lists.newArrayList("twitterapi", "#yolo"));

  Authentication auth = new OAuth1(consumerKey, consumerSecret, token, secret);
  // Authentication auth = new BasicAuth(username, password);

  // Create a new BasicClient. By default gzip is enabled.
  Client client = new ClientBuilder()
          .hosts(Constants.STREAM_HOST)
          .endpoint(endpoint)
          .authentication(auth)
          .processor(new StringDelimitedProcessor(queue))
          .build();

  // Establish a connection
  client.connect();

  // Do whatever needs to be done with messages
  for (int msgRead = 0; msgRead < 1000; msgRead++) {
    String msg = queue.take();
    System.out.println(msg);
  }

  client.stop();

}
 
开发者ID:twitter,项目名称:hbc,代码行数:30,代码来源:FilterStreamExample.java

示例14: init

import com.twitter.hbc.core.endpoint.StatusesFilterEndpoint; //导入依赖的package包/类
@PostConstruct
public void init() {
	BlockingQueue<String> queue = new LinkedBlockingQueue<>(100);
	StatusesFilterEndpoint endpoint = new StatusesFilterEndpoint();

	endpoint.trackTerms(ImmutableList.of("ExtJS", "#extjs", "Sencha", "#java",
			"java8", "java9", "#websocket", "#SpringFramework", "html5", "javascript",
			"#kotlin", "kotlin"));
	endpoint.languages(ImmutableList.of("en", "de"));

	String consumerKey = this.environment.getProperty("twitter4j.oauth.consumerKey");
	String consumerSecret = this.environment
			.getProperty("twitter4j.oauth.consumerSecret");
	String accessToken = this.environment.getProperty("twitter4j.oauth.accessToken");
	String accessTokenSecret = this.environment
			.getProperty("twitter4j.oauth.accessTokenSecret");

	Authentication auth = new OAuth1(consumerKey, consumerSecret, accessToken,
			accessTokenSecret);

	this.client = new ClientBuilder().hosts(Constants.STREAM_HOST).endpoint(endpoint)
			.authentication(auth).processor(new StringDelimitedProcessor(queue))
			.build();

	this.executorService = Executors.newSingleThreadExecutor();

	TwitterStatusListener statusListener = new TwitterStatusListener(
			this.messagingTemplate, this.lastTweets);
	this.t4jClient = new Twitter4jStatusClient(this.client, queue,
			ImmutableList.of(statusListener), this.executorService);

	this.t4jClient.connect();
	this.t4jClient.process();
}
 
开发者ID:ralscha,项目名称:spring4ws-demos,代码行数:35,代码来源:TwitterHandler.java

示例15: TwitterClient

import com.twitter.hbc.core.endpoint.StatusesFilterEndpoint; //导入依赖的package包/类
public TwitterClient() {
	/** Set up your blocking queues: Be sure to size these properly based on expected TPS of your stream */
	BlockingQueue<String> msgQueue = new LinkedBlockingQueue<String>(100000);
	BlockingQueue<Event> eventQueue = new LinkedBlockingQueue<Event>(1000);

	/** Declare the host you want to connect to, the endpoint, and authentication (basic auth or oauth) */
	Hosts hosebirdHosts = new HttpHosts(Constants.STREAM_HOST);
	StatusesFilterEndpoint hosebirdEndpoint = new StatusesFilterEndpoint();
	// Optional: set up some followings and track terms
	List<Long> followings = Lists.newArrayList(1234L, 566788L);
	List<String> terms = Lists.newArrayList("twitter", "api");
	hosebirdEndpoint.followings(followings);
	hosebirdEndpoint.trackTerms(terms);

	// These secrets should be read from a config file
	Authentication hosebirdAuth = new OAuth1("consumerKey", "consumerSecret", "token", "secret");

	ClientBuilder builder = new ClientBuilder()
	  .name("Hosebird-Client-01")                              // optional: mainly for the logs
	  .hosts(hosebirdHosts)
	  .authentication(hosebirdAuth)
	  .endpoint(new StatusesSampleEndpoint())
	  .processor(new StringDelimitedProcessor(msgQueue))
	  .eventMessageQueue(eventQueue);                          // optional: use this if you want to process client events

	Client hosebirdClient = builder.build();
	// Attempts to establish a connection.
	hosebirdClient.connect();
}
 
开发者ID:flaxsearch,项目名称:hackday,代码行数:30,代码来源:TwitterClient.java


注:本文中的com.twitter.hbc.core.endpoint.StatusesFilterEndpoint类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。