Skip to content

Tweet from LinkIt Smart Duo

Alex Simon edited this page Feb 7, 2016 · 2 revisions

Setup an app

  1. Visit: https://apps.twitter.com/
  2. Go to Keys and Access Tokens
  3. Copy the Consumer Key and Secret
  4. Create a new token, and copy the Access Token Key and Secret

NOTE: make sure the app has Read and Write permission

Setup LinkIt Smart Duo

  1. pip install python-twitter

Code

import twitter

# Twitter variables
twitterCK = '***'  # Consumer Key
twitterCS = '***'  # Consumer Secret
twitterATK = '***'  # Access Token Key
twitterATS = '***'  # Access Token Secret

def tweet():
    api = twitter.Api(consumer_key=twitterCK,
                      consumer_secret=twitterCS,
                      access_token_key=twitterATK,
                      access_token_secret=twitterATS)

    try:
        message = 'My tweet'
        status = api.PostUpdate(message)
    except twitter.TwitterError:
        print "Error in posting twitter Update"
    print status
Clone this wiki locally