Last active
July 18, 2018 02:34
-
-
Save brizental/f781b581c2a3153fa086e5ddc6539803 to your computer and use it in GitHub Desktop.
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 Twit = require('twit') | |
const T = new Twit({ | |
consumer_key: '<segredo>', | |
consumer_secret: '<segredo>', | |
access_token: '<segredo>', | |
access_token_secret: '<segredo>' | |
}) | |
module.exports = exports = () => { | |
console.log('Getting Twitter posts.') | |
return T.get( | |
'/search/tweets.json', | |
{ q: 'kanye' , result_type: 'popular' } | |
) | |
.catch(err => console.log("Error getting latest tweets.", err)) | |
.then( | |
res => { | |
if (!res.data.errors) { | |
// SUCESSO | |
console.log('Twitter:' + data.length) | |
return data | |
} else { | |
console.log("Error getting latest tweets.", err) | |
} | |
}, | |
err => console.log("Error getting latest tweets.", err) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment