PROBLEM
So im trying to create a twitter bot and everything was going fine until i tried to auto reply to users who follow me. I'am learning and was watching from this tutorial Coding Train Twitter Bot(LINK) but i seem to get this error(PHOTO) even tho i did everything exactly the same.
Im Using:
Importing Packages
var Twit = require('twit');
var Keys = require('./private_auth_keys');
var T = new Twit(Keys);
Stream Setup.
I belive the bug is somewhere in the stream part but i dont get it... i did everything the same as the video. Maybe twitter blocked this from their API? idk what im talking about, but any feedback would be awesome.
var stream = T.stream('user');
stream.on('follow', followed);
function followed(eventMsg) {
console.log("New Follower Reply Sent!");
var Name = eventMsg.source.name;
var screenName = eventMsg.source.screen_name;
tweetIt('Heyyy .@' + screenName + ' thanks for the follow! Do you like memes? #RateThatMeme');
}
Reply/Tweet Function
function tweetIt(txt) {
var tweet = {
status: txt
}
T.post('statuses/update', tweet, tweeted);
function tweeted(err, data, response) {
if (err) {
console.log("oof! Something went wrong!");
} else {
console.log("Tweet sent successfully!");
}
}
}
Error Message
events.js:167 throw er; // Unhandled 'error' event ^
Error: Bad Twitter streaming request: 401 at Object.exports.makeTwitError (C:\Users\admin\Desktop\Projects Code Train\node\node2\node_modules\twit\lib\helpers.js:74:13)....etc
Twitter user streams were retired in August so this code will no longer work as is.