twitter-tokens
v1.0.3
Published
get twitter tokens
Downloads
19
Readme
twitter-tokens
get twitter tokens
Use with twitter or twit package. Twitter tokens is basically
an object of twitter tokens exported from environment.
At some point of twitter api usage I become tired to copy-pasted tokens.js
file in a lot of my projects, so I decided to extract this file to separate npm package.
You need to get Twitter API tokens first to be able to use this package.
Install
npm install --save twitter-tokens
Usage
import Twitter from 'twitter'; // or 'twit'. it works with both of them
/* Before:
const tokens = {
consumer_key: process.env.TWITTER_CONSUMER_KEY,
consumer_secret: process.env.TWITTER_CONSUMER_SECRET,
access_token: process.env.TWITTER_ACCESS_TOKEN_KEY,
access_token_key: process.env.TWITTER_ACCESS_TOKEN_KEY,
access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET
}); */
// Now:
import tokens from 'twitter-tokens';
const client = new Twitter(tokens);
const params = { screen_name: 'nodejs' };
client.get('statuses/user_timeline', params, (err, tweets) => {
if (err) throw err;
console.log(tweets);
});
Related
- get-tweets — get latest tweets
- get-twitter-info — get info about target username
- get-twitter-followers — get followers for target username
- tweet-links — extract links from tweet
- tweets-stats — get statistics from array of tweets
- twitter-mentions — get latest mentions for target username
- twitter-profile-media — get twitter profile image and banner
License
MIT © Vladimir Starkov