Last active
July 4, 2017 12:37
-
-
Save godfreyd/e48b6831d785e51ee6ce0892151e3395 to your computer and use it in GitHub Desktop.
This file contains 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
var Twitter = require('twitter'); | |
module.exports = function getContent(config, params) { | |
return new Promise(function(resolve, reject) { | |
new Twitter(config).get('search/tweets', params, function(err, data) { | |
if (err) return reject(err); | |
if(!data.statuses.length) return resolve({}); | |
resolve({ | |
nextPageId: data.statuses[data.statuses.length -1].id, | |
tweets: data.statuses.map(function(item) { | |
var user = item.user; | |
return { | |
name: user.name, | |
time: item.created_at, // UTC time | |
q: params.q, | |
id: item.id, | |
url: 'https://twitter.com/' + user.screen_name + '/status/' + item.id_str, | |
avatar: user.profile_image_url, | |
message: item.text, | |
service: 'twitter' | |
}; | |
}) | |
}); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment