Exploring the Twitter SDK
In the previous section, we explored how to listen to tweets based on hashtags. Let's now explore the Twitter SDK to understand the capabilities that we can bestow upon our Twitter bot.
Updating your status
You can also update your status on your Twitter timeline by using the following status update module code:
tweet ('I am a Twitter Bot!', null, null);
function tweet(statusMsg, screen_name, status_id){
console.log('Sending tweet to: ' + screen_name);
console.log('In response to:' + status_id);
var msg = statusMsg;
if (screen_name != null){
msg = '@' + screen_name + ' ' + statusMsg;
}
console.log('Tweet:' + msg);
Twitter.post('statuses/update', {
status: msg
}, function(err, response) {
// if there was an error while tweeting
if (err) {
console.log('Something went wrong while TWEETING...');
console.log(err);
}
else if (response...