Login into twitter from personal website

83 views Asked by At

I wish to create a login for my website using Twitter. I wish to let the user type his Twitter Handle inside a textbox and once he enters I need to validate it by making an API call to Twitter and confirm that and need to display the Twitter name of the user and his twitter profile pic. Is this possible using plain JavaScript to implemet this feature? As Twitter is using OAuth for authentication now, can this be implemented with only JS? Kindly, pass on any links if you know. Thanks in advance :)

1

There are 1 answers

0
Gaurav On

After some research, I cam across this amazing node based API, twit, whcih can be installed just by saying npm install twit. You can also get the details on https://github.com/ttezel/twit.

Best part of this plugin is, it takes care of all the authorization with Twitter and gives you a set of methods.

Code example :

var twit = require('twit');
      var T = new twit(config_parameters); // contains you access tokens;
      T.get('users/show', { screen_name: twitterHandleName},
                            function(err, data, response) {
                                console.log(data);      
                           });
      });

It has many utility methods that help to resolve your queries that you require from Twitter