spikeyman00
spikeyman00

Reputation: 9

Python tweepy.API 'API' object has no attribute 'show_friendship'

I cant seem to get this working it seems correct according to the twitter.api it compaires source_screen_name and target_screen_name

api = tweepy.API(auth, wait_on_rate_limit=True)

thisAccount = 'myaccount'
FollowerList = pd.read_csv("Followers.csv")

#goes through list of potential followers and follow all those that are not currently following the source account
for i in range(0, FollowerList['Follower'].size):
    user = FollowerList['Follower'][i]
    friendship = api.show_friendship(source_screen_name = thisAccount, target_screen_name = user)
    following = friendship[0].followed_by
    if(not following):
        try:
            api.create_friendship(user)
        except tweepy.errors.TweepError:
            print('RateLimit hit, sleeping for 15 minutes')
            now = datetime.now()
            current_time = now.strftime("%H:%M:%S")
            print("Current Time =", current_time)
            time.sleep(15 * 60)
            continue

https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/get-friendships-show

Im getting AttributeError: 'API' object has no attribute 'show_friendship' I tried chnaging this to get_friendship but its not used in the same way.

Thanks a lot for your help. I think it might be a bit out of date. Thanks

Upvotes: 0

Views: 541

Answers (1)

Mickaël Martinez
Mickaël Martinez

Reputation: 1843

The wrapper for the friendships/show endpoint is now the get_friendship method.

It was renamed from show_friendship since the 4.0.0 version of Tweepy.

And since this is simply a renaming, there is no reason for it to have a different output.

Upvotes: 1

Related Questions