I have some code that calls a function from the Tweepy API per the docs:
api = tweepy.API(auth)
...
api.create_friendship(tweet.user.id)
Alternatively I've tried with the overload:
api.create_friendship(tweet.user.username)
Either implementation yields the error:
create_friendship() takes 1 positional argument but 2 were given
Doing some research this error can be avoided by passing in an instance of self into the function, which looks like this:
@payload('user')
def create_friendship(self, **kwargs):
""" :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/post-friendships-create
"""
return self.request(
'POST', 'friendships/create', endpoint_parameters=(
'screen_name', 'user_id', 'follow'
), **kwargs
)
However I'm just running a simple script that isn't part of a class so I don't have any scope related to self. Is there an easy way around this?
Using python 3.9