Last active
March 11, 2022 08:56
-
-
Save WEEFAA/4d13336fb88cdd2f5715e84c503e4ff1 to your computer and use it in GitHub Desktop.
[Tweetur] Getting started with Tweetur: 2 Legged OAuth Flow or "Client Credentials Flow"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Tweetur = require('tweetur') // | |
| //initialize the Tweetur app... | |
| const app = new Tweetur({ | |
| consumer_key : "api_key", // required ** | |
| consumer_secret: "api_secret", // required ** | |
| access_token: "access_token", // required ** | |
| access_token_secret: "access_token_secret", // required ** | |
| api_version: "1.1" // if you want to use Twitter v2, change the value to '2' | |
| }) | |
| // must call 'authenticate' before calling any endpoints. | |
| app.authenticate(function(err, token_data){ | |
| // we're simply throwing err for now | |
| if(err) throw err | |
| // otherwise call your endpoints here | |
| // our api call | |
| app.get('statuses/user_timeline.json', { screen_name: "twitterdev" }, callback) | |
| }) | |
| // call this block of code when the request is done | |
| function callback(err, data){ | |
| if(err) return console.error(err) | |
| // log fetched data | |
| // @aelfestijo | |
| console.log(data) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment