Error 404 with the var stream
hello i want to create a script who send a welcome message when someone follow me
so i create a test :
`console.log('Started The bot');
var Twit = require('twit');
var config = require('./config'); var T = new Twit(config);
var stream = T.stream('user');
stream.on('follow', followedMessage);
function followedMessage(eventMsg) { console.log('+1 follow'); var fs = require('fs'); var json = JSON.parse(eventMsg); fs.writeFile("tweet.json", json) } `
and i got an error :
`events.js:292 throw er; // Unhandled 'error' event ^
Error: Bad Twitter streaming request: 404
at Object.exports.makeTwitError (C:\Users\guill\Desktop\Programmation\welcomemessage-V1.0.0\node_modules\twit\lib\helpers.js:74:13)
at Request.
someone for helping me ?
The User Stream API was retired and removed in 2018, so this unfortunately no longer works. You need to use the Account Activity API instead, and the twit library does not support that. You could take a look here to see if it might help?
https://github.com/ttezel/twit/issues/445
You can also use Twitter's autohook library. There's a full tutorial here.
@andypiper So there is no way to use twit to respond to follow events?
I am not aware of a way to use twit directly with the Account Activity API, you would have to check with the maintainers - that’s why I suggested autohook or an alternative. There’s are no “follow events” on user streams because user streams do not exist any more.