Reputation: 2683
How does one set the parameters for a request to twitter via tweepy's api.
#https://api.twitter.com/1.1/statuses/user_timeline.json?exclude_replies=true&include_rts=false
import tweepy
#assume tokens and secrets are declared
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
status = api.user_timeline('xxxxxxxxx')
What I get back from this is the "tweets and retweets" from the user inside a collection of Status objects, but I only want the user's "tweets" returned. After reading the docs, it's still unclear to me on how to modify the request url
Upvotes: 1
Views: 555
Reputation: 8217
I've found success just filtering the json object returned from user_timeline
.
This will filter out the user's retweets:
for tweetObj in status:
if hasattr(tweetObj, 'retweeted_status'):
continue
else:
print tweetObj #or whatever else you want to do
But to answer your question, you can pass the optional parameter, include_retweets
like so:
status = api.user_timeline('xxxxxxxxx', include_retweets=False)
I like the first method better because the RTs still count against your count
& maximum length
parameters.
Upvotes: 1