Exemple #1
0
 def startProducing(self):
     send = make_send(self)
     class Consumer(TwistedTwitterStream.TweetReceiver):
         def connectionFailed(this, why):
             log(self, 'connection failed (%s)' % why)
         def tweetReceived(this, data):
             if 'delete' not in data:
                 send(dict(tweet=data))
     TwistedTwitterStream.sample(TWITTER_USER, TWITTER_PASSWORD, Consumer())
#!/usr/bin/env python
# coding: utf-8

import TwistedTwitterStream
from twisted.internet import reactor

class consumer(TwistedTwitterStream.TweetReceiver):
    def connectionMade(self):
        print "connected..."

    def connectionFailed(self, why):
        print "cannot connect:", why
        reactor.stop()

    def tweetReceived(self, tweet):
        print "new tweet:", repr(tweet)

if __name__ == "__main__":
    #TwistedTwitterStream.firehose("username", "password", consumer())
    #TwistedTwitterStream.retweet("username", "password", consumer())
    TwistedTwitterStream.sample("username", "password", consumer())
    reactor.run()
Exemple #3
0
class consumer(TwistedTwitterStream.TweetReceiver):
    def connectionMade(self):
        print "connected..."

    def connectionFailed(self, why):
        print "cannot connect:", why
        reactor.stop()

    def tweetReceived(self, tweet):
        print "new tweet:", repr(tweet)

if __name__ == "__main__":
    #TwistedTwitterStream.firehose("username", "password", consumer())
    #TwistedTwitterStream.retweet("username", "password", consumer())
    TwistedTwitterStream.sample("username", "password", consumer())
    reactor.run()

########NEW FILE########
__FILENAME__ = track
#!/usr/bin/env python
# coding: utf-8

import TwistedTwitterStream
from twisted.internet import reactor

class consumer(TwistedTwitterStream.TweetReceiver):
    def connectionMade(self):
        print "connected..."

    def connectionFailed(self, why):
#!/usr/bin/env python
# coding: utf-8

import TwistedTwitterStream
from twisted.internet import reactor
import oauth

class consumer(TwistedTwitterStream.TweetReceiver):
    def connectionMade(self):
        print "connected..."

    def connectionFailed(self, why):
        print "cannot connect:", why
        reactor.stop()

    def tweetReceived(self, tweet):
        print "new tweet:", repr(tweet)

if __name__ == "__main__":
    #TwistedTwitterStream.firehose("username", "password", consumer())
    #TwistedTwitterStream.retweet("username", "password", consumer())
    OAconsumer = oauth.OAuthConsumer('uu', 'bb')
    token = oauth.OAuthToken('xx', 'zz')
    TwistedTwitterStream.sample("username", "password", consumer(), OAconsumer=OAconsumer, token=token)
    reactor.run()