Categories
JavaScript Nodejs

How to Incorporate Twitter Functionality into Your Node.js App

Spread the love

If you incorporated Twitter sign in functionality according to https://medium.com/@hohanga/how-to-add-twitter-sign-in-to-your-node-js-back-end-with-angular-app-as-the-front-end-d90213f95703, then it is very easy to incorporate Twitter functionality into your app by calling the Twitter API. To get the consumer key and secret, and find out how to get the OAuth access token and secret from Twitter which you will use with the Twitter API, follow https://medium.com/@hohanga/how-to-add-twitter-sign-in-to-your-node-js-back-end-with-angular-app-as-the-front-end-d90213f95703

Once you have the OAuth access token and secret, calling Twitter API is a piece of cake. For Node.js, I had success with https://www.npmjs.com/package/twit.

You simply pass in whatever credentials are requested to build the Twit object, which allows you to call the Twitter API.

Once that is done, you can do many things which otherwise has to be done manually.

According to https://www.npmjs.com/package/twit, here are the endpoints that it can call:

  • GET ‘statuses/update’
  • GET ‘search/tweets’
  • GET ‘followers/ids’
  • GET ‘account/verify_credentials’
  • POST ‘statuses/retweet/:id’
  • POST ‘statuses/destroy/:id’
  • GET ‘users/suggestions/:slug’
  • POST ‘media/upload’
  • ‘media/metadata/create’
  • ‘statuses/filter’

All the basic functionality like tweeting, uploading photos, and streaming can be used with this library, which means that you can automate tweeting and getting data from your account.

The full list of endpoints are at https://developer.twitter.com/en.html

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *