我正在尝试运行ntwitter
流 API 来跟踪有关某个主题标签的推文,Tweets
并使用每条推文填充 Mongo 集合。
我已经将它连接到服务器端,如下所示:
t = new nTwitter({
consumer_key: credentials.consumer_key,
consumer_secret: credentials.consumer_secret,
access_token_key: credentials.access_token_key,
access_token_secret: credentials.access_token_secret
});
Meteor.methods({
trackTweets: function () {
this.unblock; // this doesn't seem to work
console.log('... ... trackTweets');
var _this = this;
t.stream(
'statuses/filter',
{ track: ['#love'] },
function(stream) {
stream.on('data', function(tweet) {
// app/packages/mongo-livedata/collection.js:247
// throw e;
// ^
// O yes I love her like money
// Error: Meteor code must always run within a Fiber
console.log(tweet.text);
Tweets.insert(tweet.text); // this call blocks
});
stream.on('error', function(error, code) {
console.log("My error: " + error + ": " + code);
});
}
);
}
});
这条线:Tweets.insert(tweet.text)
抛出must run inside its own Fiber error
- 并且我尝试将this.unblock
语句放在几个不同的地方。
我应该在这里做什么?