的Twitter的API:更新工作,但过滤器不

问题描述:

的Twitter的API:更新工作,但过滤器不 的JavaScript Twitter的OAuth的Twitter的API jsoauth的Twitter的API:更新工作,但过滤器不

在下面的代码,我从jsOAuth库实例的OAuth实例通过bytespider

// jsoauth API reference: 
    // http://bytespider.github.com/jsOAuth/api-reference/ 

    var twitter = new OAuth(oauthOptions); 

    //authentication occurs 

    console.log('url: ' + url); 
    console.log('data: ' + JSON.stringify(data)); 

    twitter.post(
     url, 
     data, 
     success, 
     failure 
    ); 

当我访问流:

url: https://stream.twitter.com/1/statuses/filter.json 
    data: {"track":"%40twitterapi"} 
    --> This does not work, neither the `success` nor `failure` callbacks get called, just hangs 

当我鸣叫:

url: https://api.twitter.com/1/statuses/update.json 
    data: {"status":"foobar","trim_user":true,"include_entities":true} 
    --> This works, the `success` callback gets called 

我的猜测是,验证信息不是通过向stream.twitter.com API获得,即使它打通至api.twitter.com API。可以安全地排除OAuth问题,因为推文能够证明身份验证已成功。

我在这里做错了什么?

谢谢!

这并不是说

这不起作用,无论是success也不failure回调得到 叫,只是因为你使用的是Streaming API,这是为了“挂”挂起

,因为使用这意味着你正在开启与Twitter服务器的连接,只要应用程序正在运行,服务器就会保持活动状态。然后每一条新的推文都会通过管道实时发送到这个连接。

你应该看看使用HTML5 WebSockets

+0

+1 && check @ Arvin:没有想到它是流式传输,因为它出现在其“REST API”部分(https://dev.twitter.com/docs/api)下。感谢您指出了这一点! – bguiz 2012-07-07 11:34:16

+0

@ Arvin:我在这里问了一个跟进问题:http://stackoverflow.com/questions/11374771/how-to-make-twitter-streaming-apis-work-with -jsoauth如果你知道如何做到这一点与HTML5 WebSockets,并想展示如何,这将是非常好的! – bguiz 2012-07-07 12:27:12