2012-12-20 85 views
0

我正在嘗試運行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聲明在幾個不同的地方。

我應該在這裏做什麼?

回答

1

你不調用函數疏通,你需要它來取代你的

this.unblock; 

this.unblock(); 

,如果不行,我會認爲這事做的方式ntwitter正在獲取數據,您可以嘗試添加此數據

if (Meteor.isClient) return false; 

以便該方法不會在c上運行只有在服務器上

相關問題