tweepy stream.filter()方法无法正常工作 [英] tweepy stream.filter() method doesn't work properly

查看:695
本文介绍了tweepy stream.filter()方法无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我只是试着写一个小应用程序,让我得到一个用户的状态流(矿石更多),但一个将罚款开始; - )

现在:我的代码是这样的:

  def main():
config = ConfigParser.ConfigParser()
config.read('twitter.cfg')

username = config.get('Twitter','username')
password = config.get('Twitter','password')
listener = StreamWatcherListener()

stream = tweepy.Stream(username,password,listener,timeout = None)
stream.filter('132897940')


$在StreamWatcherListener中有$ b

我有一个方法on_status打印一个状态的文本,每当一个新的到来(一切似乎工作,当我尝试stream.sample(),而不是stream.filter())

给定的ID是我的testaccount,所以每当我推特我应该在控制台中得到一些响应....但没有任何反应。

当我尝试时



<$ p $ curl -d @following http://stream.twitter.com/1/statuses/filter.json -uAnyTwitterUser:Password

在终端,我可以找到在Twitter的API,一切运行良好。

所以也许我做错了() - 方法?

有什么建议吗?

$ and $ $ b $

stream.filter() 方法需要一个数组

所以我必须编码

  stream.filter(['1234567'])

etvoilà


i've got some problems with the tweepy api.

I'm just tryin to write a little app that gets me a stream of statuses of one user (ore more), but one would be fine to start with ;-)

now: my code is like that:

    def main():
       config = ConfigParser.ConfigParser()
       config.read('twitter.cfg')

       username = config.get('Twitter', 'username')
       password = config.get('Twitter', 'password') 
           listener = StreamWatcherListener()

       stream = tweepy.Stream(username, password, listener, timeout=None)
       stream.filter('132897940')

in StreamWatcherListener I have a method "on_status" that prints the text of a status, whenever a new one arrives (everything seems to work, when I try stream.sample() instead of stream.filter())

the given ID is my testaccount, so whenever I tweet I should get some response in the console....but nothing happens.

when I try

curl -d @following http://stream.twitter.com/1/statuses/filter.json -uAnyTwitterUser:Password

in the terminal as I could find in the twitter api, everything runs fine.

So maybe I make wrong use of the filter()-method?

any suggestions?

-andy

解决方案

I found it out myself

the stream.filter() method needs an array

so i had to code

stream.filter(['1234567'])

et voilà

这篇关于tweepy stream.filter()方法无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆