I'm using node and express to access the twitter api. the following code gives me a 401 error. I've tried changing my apps access to read, write and access, and regenerating my api keys, but that still gives me an error saying that it can't authenticate me. I read on the twitter forums that leaving the url callback field in the api app settings might be causing this, but that didn't fix it either.
const port = (process.env.VCAP_APP_PORT || 3000);
const express = require("express");
const twitter = require('twitter');
const app = express();
const twitterClient = new twitter({
consumer_key: 'key',
consumer_secret: 'key',
access_token_key: 'key-key',
access_token_secret: 'key'
});
app.get('/hello', (req, res) => {
twitterClient.stream('statuses/filter', {track: 'javascript'}, function(stream) {
stream.on('data', function(event) {
console.log(event && event.text);
});
stream.on('error', function(error) {
throw error;
});
});
});
via Shayan Javadi
No comments:
Post a Comment