Support
Quality
Security
License
Reuse
kandi has reviewed tweepy and discovered the below as its top functions. This is intended to give you an instant insight into tweepy implemented functionality, and help decide if they suit your requirements.
Twitter for Python!
default
The easiest way to install the latest version from PyPI is by using
[pip](https://pip.pypa.io/):
pip install tweepy
To use the `tweepy.asynchronous` subpackage, be sure to install with the
`async` extra:
pip install tweepy[async]
You can also use Git to clone the repository from GitHub to install the latest
development version:
git clone https://github.com/tweepy/tweepy.git
cd tweepy
pip install .
Alternatively, install directly from the GitHub repository:
pip install git+https://github.com/tweepy/tweepy.git
Python 3.6 - 3.10 are supported.
Links
-----
- [Documentation](https://tweepy.readthedocs.io/en/latest/)
- [Official Discord Server](https://discord.gg/bJvqnhg)
- [Twitter API Documentation](https://developer.twitter.com/en/docs/twitter-api)
QUESTION
How to solve AttributeError: 'Client' object has no attribute 'apply_auth'?
Asked 2022-Apr-08 at 20:48I'm having trouble with new and old documentation of tweepy, it seems that everything that worked in previous versions, but there are a lot of changes, I have a problem making it work right now. Any ideas why I have this error?
import tweepy
client = tweepy.Client(bearer_token='[redacted]',
consumer_key='[redacted]',
consumer_secret='[redacted]',
access_token='[redacted]',
access_token_secret='[redacted]')
api = tweepy.API(client)
public_tweets = api.home_timeline()
for tweet in public_tweets:
print(tweet.text)
I get this error
AttributeError: 'Client' object has no attribute 'apply_auth'
ANSWER
Answered 2022-Apr-08 at 18:25First of all, you should IMMEDIATELY refresh all your personnal and applications tokens.
Anyone can access the Twitter API on your behalf, it's like sharing your password publicly.
About your question: the tweepy.Client
is used to access the version 2 of the Twitter API, while the tweepy.API
is used to access the version 1.1 of the Twitter api.
So you can use them side by side, but they can not be mixed that way.
A quick fix could be:
auth = tweepy.OAuth1UserHandler(
consumer_key, consumer_secret, access_token, access_token_secret
)
api = tweepy.API(auth)
public_tweets = api.home_timeline()
for tweet in public_tweets:
print(tweet.text)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported