TwitterJSClient icon indicating copy to clipboard operation
TwitterJSClient copied to clipboard

pls correct readme because twitter_config not work

Open odykyi opened this issue 8 years ago • 5 comments

Where I need to create this config? I try create twitter_config file in root and in data directory its not work

/node_modules/twitter-node-client/lib/Twitter.js:9
    this.consumerKey = config.consumerKey;
                             ^

TypeError: Cannot read property 'consumerKey' of undefined

{
    	"consumerKey": "XXX",
    	"consumerSecret": "XXX",
    	"accessToken": "XXX",
    	"accessTokenSecret": "XXX",
    	"callBackUrl": "XXX"
}

Please create example folder in your repository with example twitter application

odykyi avatar Oct 05 '17 08:10 odykyi

It works when you pass your consumer key and access token as process envs, like this:

twitterConsumerKey=<example> twitterConsumerSecret=<example> twitterAccessToken=<example> twitterAccessTokenSecret=<example> node index.js

davidvexel avatar Oct 20 '17 13:10 davidvexel

ok pls add this to readme twitterConsumerKey=<example> twitterConsumerSecret=<example> twitterAccessToken=<example> twitterAccessTokenSecret=<example> node index.js

odykyi avatar Oct 28 '17 23:10 odykyi

@odykyi it just worked for me, I'm not the developer of this plugin.

davidvexel avatar Oct 29 '17 02:10 davidvexel

I know this is an old thread, but I still wanted to chip in on Craig's earlier guide...

While environment variables are okay, you only need to read the twitter_config file as string, and then JSON.parse it into the function as an object. Here's how I did it..

    var fs = require('fs');
    fs.readFile('data/twitter_config', 'utf8', function(err, contents) {
         var twitter = new Twitter(JSON.parse(contents));
    });

Works fine.

chiemekailo avatar Nov 22 '18 17:11 chiemekailo

@chiemekailo could you pls create PR and update readme with yours example thanks

odykyi avatar Nov 23 '18 10:11 odykyi