#Accessing Twitter API with Node and ntwitter
The purpose of this application is to demonstrate two simple examples of how to access Twitter's API from a server written in Node.js. This application uses ntwitter, which can be found on github here. The use cases demonstrated are
-
An application that only makes calls on its own behalf. An example of this would be an analytics application which is using the API on its on behalf. This is referred to as the Single User Example in the Application code.
-
An application which allows users to 'Sign in' with Twitter. An example of this type of application might be a News site which allows its Users to sign-in using their Twitter identies rather than creating their own accounts. This is referred to as the Sign in Twitter Example.
The Consumer and Ouath Keys in the repository are invalid. They are left in there to make it easier to correlate the screenshots to the code
##Setup on Twitter
-
Sign into Twitter
-
Go to https://dev.twitter.com/apps/new to create a new application
-
Create App as seen here
This will create the application specific Token and Secret required.
-
Create User Tokens.
In addtion to creating Application specific Token and Secret, we also need to generate user specific tokens.
To do this select 'Create my access token' at the bottom of the application overview page.
-
Verify you have both a Consumer Secret and an Oauth Token created.
Go to the Oauth Tab on the Application Overview page to verify you have all 4 keys/tokens.
See the screenshot below
##Setup Local
The two main packages here are express and ntwitter
-
Install Express
$ npm install express
-
Install ntwitter
$ npm install ntwitter
-
Run the Server
$ node app.js
-
Update app.js with correct tokens/keys
Search for TODO in app.js to find all necessary code that needs to be updated
-
Connect to Server via Browser
Go to http://localhost:3000