GitXplorerGitXplorer
p

mtwitter

public
37 stars
5 forks
0 issues

Commits

List of commits on branch master.
Unverified
2a692b56caa3ac94e3e06aea0d41e0133142cca9

Use function hoisting

ppasscod committed 8 years ago
Unverified
1bf07371e1baa44610dd6fb3bf76699cb1c0e35b

Final unmaintained notice.

ppasscod committed 10 years ago
Unverified
eb40603772162c819e0f3df68645792514f227eb

Update badge URLs

ppasscod committed 11 years ago
Unverified
03e093816673c3557ca9d47af5a419ac1dc7b3c3

Simplify, update README

ppasscod committed 11 years ago
Unverified
79d5605d314dbec2391e4712407da5c52bc19e33

Yank node version up to 0.10

ppasscod committed 11 years ago
Unverified
0e7e3c99514f6b607f0805a211bb0929f736a63b

Update jape

ppasscod committed 11 years ago

README

The README file for this repository.

Node.js Twitter API

Build Status NPM version Dependency Status

This library is unmaintained. Use twitter or twit instead.

Instantiation & Keys

mtwitter cannot currently help with obtaining access tokens from Twitter, you'll have to do this yourself. For testing and simple apps, the keys can be obtained from dev.twitter.com after setting up a new App.

var Twitter = require('mtwitter');

Normal (client) authentication

var twitter = new Twitter({
  consumer_key: 'Twitter',
  consumer_secret: 'API',
  access_token_key: 'keys',
  access_token_secret: 'go here'
});

App-only authentication

var twitter = new Twitter({
  consumer_key: config.key,
  consumer_secret: config.secret,
  application_only: true
});

REST Interface

The REST interface is managed, which means it transparently handles rate-limiting (it retries requests and doesn't bombard the APIs), and also takes care of fetching and refreshing configuration data as recommended by Twitter.

Synopsis

twitter.get(
  '/statuses/mentions_timeline',
  {key: 'value'},
function logResponse(error, data, response) {
  console.log('Error? ', error);
  console.log('Parsed object of data: ', data);
  console.log('Raw HTTP response: ', response);
});

twitter.post(
  '/favorites/create',      // URL. Don't use https:// ones
  'id=317050755691454464',  // Body content (can be a string or hashmap)
                            // Content-Type (omit to use default)
  function() { ... }        // Callback has the same signature as above
);

Additional examples

// Get a user's timeline
twit.get('statuses/home_timeline', {screen_name: '_matthewpalmer'}, function(err, item) {
  console.log(err, item);
 });

// Search for a phrase
twit.get('search/tweets', {q: 'node.js'}, function(err, item) {
  console.log(err, item);
});

// Post a new status
var content = {status: 'Maybe he\'ll finally find his keys. /@peterfalk'};
twit.post('statuses/update', content, function(err, item) {
  console.log(err, item);
});

Streaming

For the moment, only "raw" access is available:

twit.stream.raw(
  'GET',
  'https://stream.twitter.com/1.1/statuses/sample.json',
  {delimited: 'length'},
  // The above arguments are as for .rest.queueRequest()
  // i.e. the third argument has to be a {content: ...}
  // for POST. The URL has to include https://...

  process.stdout // Provide a stream to pipe to, here STDOUT
);

Community & Contributions

Originally forked from @AvianFlu's inactive repo, but reworked heavily, taking inspiration from many people and their attempts at making it better. Old (pre-rewrite) contributors can be found in HISTORICAL. Contributors to the present iteration can be found in the package.json.

License: Public Domain.
Style guide: passcod/node-style-guide.

Contributing

See CONTRIBUTING.md for details

  • Topical branches and standard PR etiquette is preferred.

  • You need to formally agree to release your contribution.

  • Both linting and testing should pass (the Travis build will fail a PR if there are linting errors):

    $ npm test
    $ npm run-script lint