これが私のコードです...リツイートではなく、個々のツイートを取得するために機能します。誰にもアイデアはありますか?:(
import tweepy
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
ACCESS_TOKEN = ''
ACCESS_TOKEN_SECRET = ''
def OAuth():
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
class CustomStreamListener(tweepy.StreamListener):
def on_status(self, status):
try:
geo = status.geo.get("coordinates")
lat = geo[0]
lon = geo[1]
text = status.text
print status.id ,status.author.screen_name, text, status.created_at, status.retweeted, status.retweet_count
except Exception, e:
#sys.stdout.write("-")
print "StreamListener Error: %s" %e
def on_error(self, status_code):
print("status_code %d")%(status_code)
return False #Kill the Stream
def on_timeout(self):
print("On_timeout")
return False #Kill the Stream
def main():
# Call method to establish the connection to twitter
status_wrapper = TextWrapper(width=60, initial_indent=' ', subsequent_indent=' ')
auth = OAuth()
api = tweepy.API(auth)
api.verify_credentials()
dateTime = time.strftime("%Y/%m/%d %H:%M:%S")
text = "Tweet this msg from my app at %s" %dateTime
api.update_status(text)
profile = api.get_user('xxxxxxxx')
user = profile.screen_name
id = profile.id
print("%s : %s") %(user, id)
while True:
try:
streaming = tweepy.streaming.Stream(auth, CustomStreamListener(), timeout=3000000000)
streaming.filter(follow=[id])
except Exception, e :
print e
main()
次に、メッセージをリツイートしようとテストしたところ、このエラーが発生しました...
StreamListener Error: 'NoneType' object has no attribute 'get'
通常のツイートの一部で、それは行われました...
367259704327544832 xxxxxxxx Test sending a msg 2013-08-13 12:21:51 False 0