Skip to content

Instantly share code, notes, and snippets.

@astrotars
Last active October 1, 2018 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save astrotars/aded0989b0f9f93e77a484a0941465c0 to your computer and use it in GitHub Desktop.
Save astrotars/aded0989b0f9f93e77a484a0941465c0 to your computer and use it in GitHub Desktop.
module.exports.crawl = () => {
twitterClient.get(
'search/tweets',
{ q: '@FlyFrontier', count: 100 },
(err, data, res) => {
data.statuses.map(status => {
streamClient
.feed('timeline', 'all')
.addActivity({
actor: streamClient.collections.createUserReference(
status.user.screen_name
),
verb: 'tweet',
object: status.text,
attachments: {
og: {
title: status.text,
description: 'via Aviato for Twitter',
url: `https://twitter.com/${
status.user.screen_name
}/status/${status.id_str}`,
images: [
{
image:
'https://pbs.twimg.com/profile_images/700447615062642688/fXsrshge_400x400.jpg'
}
]
}
},
time: moment(
status.created_at,
'ddd MMM DD HH:mm:ss ZZ YYYY'
).toISOString(),
foreign_id: status.id_str
})
.then(res => {
streamClient.collections
.upsert('user', {
id: status.user.screen_name,
name: '@' + status.user.screen_name,
profileImage:
status.user.profile_image_url_https
})
.then(res => {
callback(null, res);
})
.catch(err => {
callback(err);
});
})
.catch(err => {
callback(err);
});
});
}
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment