我正在嘗試運行ntwitter
流式API來跟蹤關於某個哈希標籤的推文,並在每條推文中填充Mongo集合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
聲明在幾個不同的地方。
我應該在這裏做什麼?