Reputation: 113
I work on windows 7 and i am trying to access twitter using tweepy and even twitter1.14.2-python.But i am not able crack it. Help needed.
TWEEPY
import tweepy
OAUTH_TOKEN = "defined here"
OAUTH_SECRET = "defined here"
CONSUMER_KEY = "defined here"
CONSUMER_SECRET = "defined here"
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(OAUTH_TOKEN, OAUTH_SECRET)
api = API.GetUserTimeline(screen_name="yyy")
Error : name 'API' is not defined
TWITTER 1.14.2
import twitter
from twitter import *
tw = Twitter(auth=OAuth(OAUTH_TOKEN, OAUTH_SECRET,CONSUMER_KEY, CONSUMER_SECRET))
tw.statuses.home_timeline()
tw.statuses.user_timeline(screen_name="yyy")
Error : No module named OAuth
Where i am going wrong ?
Upvotes: 2
Views: 580
Reputation: 113
Finally i got the way out with tweepy
import tweepy
CONSUMER_KEY = 'Deliver here'
CONSUMER_SECRET = 'Deliver here'
OAUTH_TOKEN = 'Deliver here'
OAUTH_SECRET = 'Deliver here'
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(OAUTH_TOKEN, OAUTH_SECRET)
urapi = tweepy.API(auth)
me = urapi.me()
print me().name
print me().screen_name
print me.followers_count
for status in tweepy.Cursor(myapi.user_timeline,id="abby").items(2):
print status.text+"/n"
Upvotes: 1
Reputation: 5409
As there is no GetUserTimeline
defined/declared in tweepy.API class, so am asuming that you intend to try the GetUserTimeline
method of twitter.Api class.
The API
is exposed via the twitter.Api
class.
To create an instance of the twitter.Api
class:
>>> import twitter
>>> api = twitter.Api()
To create an instance of the twitter.Api
with login credentials.
>>> api = twitter.Api(consumer_key='consumer_key',
consumer_secret='consumer_secret', access_token_key='access_token',
access_token_secret='access_token_secret')
To fetch a single user's public status messages, where user
is either a Twitter "short name" or their user id
>>> statuses = api.GetUserTimeline(user)
>>> print [s.text for s in statuses]
Upvotes: 2