Skip to content

Instantly share code, notes, and snippets.

@echohtp
Created July 9, 2020 16:48
Show Gist options
  • Save echohtp/2716c6dd8acef226723233932169ea99 to your computer and use it in GitHub Desktop.
Save echohtp/2716c6dd8acef226723233932169ea99 to your computer and use it in GitHub Desktop.
Easy update twitter username w/ followers count
import os
import tweepy
from flask import Flask
# Authenticate to Twitter
auth = tweepy.OAuthHandler("API KEY", "API SECRET")
auth.set_access_token("TOKEN", "SECRET")
# Create API object
api = tweepy.API(auth)
# Get my user object
iam = api.me()
# Get followers #
followers_count = iam.followers_count
# Update user name
api.update_profile(name="Jason Alvarez has {} followers".format(int(followers_count)))
# Spawn HTTP Server for Heroku
app = Flask(__name__)
app.run(os.environ.get('PORT'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment