node package manager
Orgs are free. Discover, share, and reuse code in your team. Create a free org »

cher-twitter

cher-twitter

A source stream implementation for cher

Usage

  const Cher = require('cher');
  const tools = require('cher-tools');
  const cherTwitter = require('cher-twitter');
  const save = tools.pipeline.save;
  // config helper 
  const config = tools.utils.config;
 
  // Cher streams get configured here. 
  const sourceStreams = [
    {
      name: 'twitter',
      module: cherTwitter
    }
  ];
 
  config.fetch({
    pipeline: [ save ],
    sourceStreams: sourceStreams
  })
  .then(Cher.construct)
  .spread((streams, cher) => {
      const twitterSource = cher.getStream('twitter');
      twitterSource
        .start()
        .spread((dataChannel, twitterSettings) => {
          dataChannel.on('data', (data) => {
            console.log(data) // a twitter post or comment or whatever 
          });
        });
    });
 

Tests

Setup some environment variables

$ echo "twitter_CLIENT_ID=<your_client_id>" >> test/test.env
$ echo "twitter_CLIENT_SECRET=<your_client_secret>" >> test/test.env
$ echo "twitterAccessToken=<your_really_long_access_token>" >> test/test.env
$ echo "PAGES=<a_fb_page_id>" >> test/test.env
$ echo "POSTS=<a_fb_post_id_with_comments>" >> test/test.env

Run em'

$ npm test