Twitter APIs : update working, but filter does not

不问归期 提交于 2019-12-25 01:23:31

问题


Twitter APIs : update working, but filter does not javascript twitter oauth twitter-api jsoauth

In the following code, I instantiate an instance of OAuth from the jsOAuth library by 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
    );

When I access the stream:

    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

When I tweet:

    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

My guess is that the authentication details are not getting through to the stream.twitter.com API, even though it get through to the api.twitter.com API. Can safely rule out OAuth issues as being able to tweet demonstrates that authentication has succeeded.

What am I doing wrong here?

Thanks!


回答1:


It's not that

This does not work, neither the success nor failure callbacks get called, just hangs

because you are using the Streaming API, which was meant to "hang", as using this means that you are opening a connection to Twitter's servers that will be kept alive as long as the application is running. Every new tweet will be then sent to this connection in realtime like water through a pipe.

You should look into using HTML5 WebSockets.



来源:https://stackoverflow.com/questions/11372835/twitter-apis-update-working-but-filter-does-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!