Twitter APIs:更新工作,但过滤器不 [英] Twitter APIs : update working, but filter does not
问题描述
Twitter APIs:更新工作,但过滤器不javascript twitter oauth twitter-api jsoauth
Twitter APIs : update working, but filter does not javascript twitter oauth twitter-api jsoauth
在下面的代码中,我通过bytespider从jsOAuth库中实例化了一个OAuth
的实例
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
);
当我访问流时:
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 问题,因为能够发送推文表明身份验证已成功.
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.
我在这里做错了什么?
谢谢!
推荐答案
不是那个
这不起作用,success
和 failure
回调都没有得到调用,只是挂起
This does not work, neither the
success
norfailure
callbacks get called, just hangs
因为您正在使用 Streaming API,这意味着挂起",因为使用这意味着您正在打开与 Twitter 服务器的连接,只要应用程序正在运行,该连接就会保持活动状态.然后,每条新推文都会像通过管道的水一样实时发送到此连接.
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.
您应该考虑使用 HTML5 WebSockets.
这篇关于Twitter APIs:更新工作,但过滤器不的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!