Skip to content

Instantly share code, notes, and snippets.

@nhindman
Created April 9, 2014 21:55
Show Gist options
  • Save nhindman/10322052 to your computer and use it in GitHub Desktop.
Save nhindman/10322052 to your computer and use it in GitHub Desktop.
var request = require("request");
var EMBEDLY_KEY = '8c394ac3008745d48fe82133e6acc577';
var embedly = require('embedly');
var util = require('util');
var summarize = function(url, callback) {
request("https://api.embed.ly/1/extract", {
qs: {url: url, key: EMBEDLY_KEY}
}, function(error, response, body) {
if (!error && response.statusCode == 200) {
callback(JSON.parse(body));
} else {
console.log("modules/embedly#summarize", error, response);
}
});
};
// exports.summarize = summarize;
var Twit = require("twit");
var embedly = require('embedly');
var T = new Twit({
consumer_key: 'i7lsLu4dOv66EEDzCWEifyoXd',
consumer_secret: '3I7NQsQsjQpCsadhN8t1Ry9Xb3oglUsDTzME6Cc0EGLvrVmZQB',
access_token: '1067293915-gXahWnpOxPZydxkzAO4YzWNfhaSkZp8Nz6KfW4L',
access_token_secret: '1e8Y0rCaLlz9SkdlIqBuMsBbEJvDY1SUb9ZClh6WNkmim',
});
var tweets = [];
var urls = [];
var urlPattern = /(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/
T.get('statuses/user_timeline', { 'screen_name' : 'BrooklynCarly', 'count': 20 }, function(err, reply) {
for (i in reply){
tweet = reply[i].text;
if (urlPattern.test(tweet)){
tweets.push(tweet);
var urlRegex = /(https?:\/\/[^\s]+)/g;
tweet.replace(urlRegex, function(tweet) {
console.log("heres a URL",tweet)
urls.push(tweet);
})
}
}
urls.forEach(function(url) {
summarize(url, function(summary) {
console.log(summary.title)
console.log(summary.description)
console.log(summary.images[0].url)
});
});
console.log(tweets.length)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment