Skip to content

Instantly share code, notes, and snippets.

@godfreyd
Last active July 4, 2017 12:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save godfreyd/e48b6831d785e51ee6ce0892151e3395 to your computer and use it in GitHub Desktop.
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