Only the v2 API is free now. Let's hope the fix is to just switch to
that version, and possibly re-generate tokens (this has worked for other
systems).
for a in articles:
# We hardcode 30 chars for the URL shortener. And then 10 to cover the intro and spacing.
statusstr = "News: {0} {1}/about/news/{2}-{3}/".format(a.title[:140 - 40], settings.SITE_ROOT, slugify(a.title), a.id)
- r = tw.post('https://api.twitter.com/1.1/statuses/update.json', data={
- 'status': statusstr,
+ r = tw.post('https://api.twitter.com/2/tweets', data={
+ 'text': statusstr,
})
- if r.status_code != 200:
+ if r.status_code != 201:
print("Failed to post to twitter: %s " % r)
else:
a.tweeted = True
raise CommandError("TWITTER_TOKENSECRET is already set in settings_local.py")
# OK, now we're good to go :)
- oauth = requests_oauthlib.OAuth1Session(settings.TWITTER_CLIENT, settings.TWITTER_CLIENTSECRET)
+ oauth = requests_oauthlib.OAuth1Session(settings.TWITTER_CLIENT, settings.TWITTER_CLIENTSECRET, callback_uri='oob')
fetch_response = oauth.fetch_request_token('https://api.twitter.com/oauth/request_token')
authorization_url = oauth.authorization_url('https://api.twitter.com/oauth/authorize')