Answer the question
In order to leave comments, you need to log in
Twitter-Api how to solve problem Pyhon-Twitter: AttributeError: 'NoneType' object has no attribute 'GetUserTimeline'?
Colleagues, the IDE gives an error.
Twitter package installed.
Here is the code:
#!/usr/bin/env python
# !-*- coding: utf-8 -*-
import os
import time
import string
import twitter
# Задержка между запросами в секундах
REQUEST_DELAY = 2
# Аккаунт Twitter для управления
TWITTER_USERNAME = 'Joshua'
# Формат даты, отдаваемой API твиттера
DATE_FORMAT = '%a %b %d %H:%M:%S +0000 %Y'
# Имя файла для записи истории "выполненных" твитов
LOG_FILE = 'history.txt'
api = twitter.Api()
while True:
statuses = api.GetUserTimeline(TWITTER_USERNAME)
try:
command = statuses[0]
except IndexError:
command = None
if isinstance(command, twitter.Status):
with open(LOG_FILE, 'a+') as f:
history = string.split(f.read(), "\n")
if not str(command.id) in history:
os.system(command.text)
f.write(str(command.id) + "\n")
f.closed
time.sleep(REQUEST_DELAY)
Traceback (most recent call last):
File "C:/Users/111/Desktop/twibot.py", line 22, in <module>
statuses = api.GetUserTimeline(TWITTER_USERNAME)
AttributeError: 'NoneType' object has no attribute 'GetUserTimeline'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question