Skip to content

Instantly share code, notes, and snippets.

@ricomoss
Created December 22, 2013 18:12
Show Gist options
  • Save ricomoss/8086345 to your computer and use it in GitHub Desktop.
Save ricomoss/8086345 to your computer and use it in GitHub Desktop.
Feeds = new Meteor.Collection('feeds');
if (Meteor.isServer) {
var twitter_user_id = 0;
var boundCallback = Meteor.bindEnvironment(function (err, resp) {
var timestamp = new Date().getTime();
if (err !== null) {
console.log(err);
return;
}
for (var obj in resp['statuses']) {
twitter_user_id = resp['statuses'][obj].user.id;
console.log(Feeds.find({feed: 'blah'}));
}
});
Meteor.startup(function () {
Feeds.remove({});
});
Meteor.methods({
twit_get: function() {
Twit = new TwitMaker({
consumer_key: 'foo',
consumer_secret: 'foo',
access_token: 'foo',
access_token_secret: 'foo'
});
Twit.get(
'search/tweets',
{
q: '#banana since_id:' + twitter_user_id,
count: 1
},
boundCallback
);
}
});
}
if (Meteor.isClient) {
Template.twitter_feeds.feeds = function () {
return Feeds.find({}, {sort: {feed: -1}});
};
Meteor.setInterval(function () { Meteor.call('twit_get'); }, 30000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment