Skip to content

Instantly share code, notes, and snippets.

@nparsons08 nparsons08/crawl.js
Last active Oct 1, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.