Comments (3)
The following code worked for me.
from TwitterAPI import TwitterAPI, TwitterRequestError, TwitterConnectionError
try:
api = TwitterAPI(
consumer_key, consumer_secret, access_token_key, access_token_secret,
auth_type='oAuth1',
api_version='2')
r = api.request('tweets', {'text':'a test to test'}, method_override='POST')
for item in r:
print(item)
except TwitterRequestError as e:
print(e.status_code)
for msg in iter(e):
print(msg)
except TwitterConnectionError as e:
print(e)
except Exception as e:
print(e)
from twitterapi.
Thanks for getting back to me so quickly @geduldig. Your code is correct, the problem was on the Twitter side of things. I'll leave steps below in case anyone else comes across this:
- App stopped working after a few years. I was using v1 of the Twitter API, which they stopped supporting. I was using a standalone Twitter app. Apps are now required to be part of a Project.
- There is an option to attach existing Apps to a Project, try that. If that doesn't work (Twitter threw errors) then you need to delete your existing App and create a new one under your Project
- In the new App setup permissions under "User authentication settings". Make sure to select "Read and write" under App permissions. This will generate OAuth2 tokens so your app can be used on other user's behalf. Even though this isn't what I'm using the app for, this step is required.
- Under the App's "Keys and Tokens" (re)generate new API Key and Secret pairs and Access Token and Secret pairs. If these existed before the previous step, they must be regenerated.
from twitterapi.
I also attempted this code and received the following error:
TwitterAPI(
oauth2_access_token=os.getenv("TWITTER_BEARER_TOKEN"),
auth_type="oAuth2User",
api_version="2",
)
api.request("tweets", {"text": "Hello World"}, method_override="POST")
Authenticating with OAuth 2.0 Application-Only is forbidden for this endpoint. Supported authentication types are [OAuth 1.0a User Context, OAuth 2.0 User Context].
from twitterapi.
Related Issues (20)
- Wrong documentation version on gh-pages HOT 1
- No includes in _RestIterable response without hydration
- lang filtering does not seem to work HOT 1
- Attempting to pull more than 10 tweets with search/tweets HOT 1
- Question: how do I acquire `screen_name` using `author_id`?? HOT 1
- DM Example not working HOT 2
- gracefully handling a stalled stream HOT 51
- Upgrade Ads API to version 10 - Deadline March 31, 2022
- Bearer Token Issue with Academic Access in Twitter API V2 HOT 1
- SUBSCRIPTION ENDPOINT NOT WORKING HOT 2
- `expansions` does not work with `author_id` HOT 2
- Twitter Ads API version 10 deprecation - End of life date September 29, 2022
- Add support for `/users/:id/bookmarks` endpoint
- Add support for OAuth2 authentication with access_tokens HOT 1
- Not able to create Webhook with Twitter HOT 2
- Request method fails to attach additional metadata HOT 2
- Authenticating error (api_version='2') HOT 8
- Can't attach media V2 HOT 2
- OP_NO_TICKET SSL Option no longer supported by Twitter HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twitterapi.