jim-easterbrook / pywws

Python software for USB Wireless WeatherStations
https://pywws.readthedocs.io/
GNU General Public License v2.0
204 stars 62 forks source link

Twitter Posting #115

Closed rick165 closed 7 months ago

rick165 commented 7 months ago

Is there any fix to the following error since twitter changed the api access? :pywws.service.twitter:TwitterError([{u'message': u'You currently have access to a subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g. media post, oauth) only. If you need access to this endpoint, you may need a different access level. You can learn more here: https://developer.twitter.com/en/portal/product', u'code': 453}],)

jim-easterbrook commented 7 months ago

No, unless someone wants to pay Twitter $100 per month for pywws to be able to post messages.

rick165 commented 7 months ago

I did wonder after it stopped working in July 23 and it hadn't been fixed yet. Shame really, oh well I'll post the stats on mastodon instead. Thanks for the feedback Jim, been using pywws for longer than I can remember 😊

rick165 commented 6 months ago

I've looked into this and I believe the free account is allowed to post up to 1500 posts a month, so in theory if the user only tweeted hourly weather conditions, it'd equate to approx 740+ tweets a month. I've managed to do a test tweet using tweepy and the new v2 api using the following code


import tweepy

CONSUMER_KEY = ""
CONSUMER_SECRET = ""
ACCESS_KEY = ""
ACCESS_SECRET = ""

# Twitter API v2 --- Will be used to post the tweet
client_v2 = tweepy.Client(
    consumer_key=CONSUMER_KEY,
    consumer_secret=CONSUMER_SECRET,
    access_token=ACCESS_KEY,
    access_token_secret=ACCESS_SECRET
)

response = client_v2.create_tweet(text="hello world")
jim-easterbrook commented 6 months ago

pywws has more than one user. If you create your own developer account and generate your own key/secret then you can post to Twitter. But if you share that key/secret (as pywws does) then all the users soon add up to more than 1500 posts per month.

rick165 commented 6 months ago

Apologies, I'd always used pywws with my own twitter account in isolation.

jim-easterbrook commented 6 months ago

There are two sets of key/secret pairs. The one corresponding to your user account, which is stored in weather.ini, and the consumer_key and consumer_secret which are stored in pywws/constants.py. It is the latter that are shared between pywws users. You can obtain your own consumer_key and consumer_secret by registering as a Twitter developer and creating a set of credentials.