Announcement

Collapse
No announcement yet.

Post to twitter feed from Snappy script

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Post to twitter feed from Snappy script

    The goal here is to update twitter feed with data generated from an automated snappy script running either on Snap Connect or on E10.
    1. Download the python-twitter module.
    2. Unzip this file into python directory and from the command line in the unzipped directory, run "python setup.py build" followed by “python setup.py install” to install the twitter module.
    3. Download and install setuptools for currently installed version of python from python-setuptools.
    4. Download the python-oauth2 module.
    5. Unzip this file into python directory and from the command line in the unzipped directory, run "python setup.py build" followed by “python setup.py install” to install the oauth2 module.
    6. Run Python and then type, “import twitter”. If you don’t get any error messages, the module has installed correctly.
    7. Go to ​http://twitter.com and create a new Twitter account for your application. (You might need to get a throwaway email address to sign up with.)
    8. Now you need to set up this account so your script can make calls to Twitter’s API. Go to ​https://dev.twitter.com/apps/new and enter in the details. For now, you can provide "​https://dev.twitter.com/apps/new" as the website URL if you don't have a webpage. You don’t need a callback URL. 6. Click “Create your Twitter Application”.
    On the new app’s web page, and under “Settings” click on the “Read, Write, and Access direct messages” radio button. This is so that your script can make posts. Click “Update this Twitter Application’s settings”.
    9. Go back to the Details tab, and at the bottom of the screen click “Create my access token”.
    10. When the page reloads, you will need to copy the following four pieces of information from this page: “Consumer Key”, “Consumer Secret”, “Access Token”, and “Access Token Secret”.
    11. Open a text editor or IDE to write Python code, or just test this code from the interactive shell (replacing the keys and secrets with the values you got for your app):
    Code:
    import twitter
    api = twitter.Api(consumer_key='og82uZE9GOLMDsQxileh65', consumer_secret='me7hXfqDOv0KZuHICWnpdxTNykQBoUrS1zVgb4ARFt', access_token_key='iINPSMrwktD4ZLn01WhfoRb7a2OJ6F38zKlYBTQcm5UvjgHGAe', access_token_secret='5Opjh1qMaHAyz2Bw9i4bxPKNLE0RFeJuYsn8TdtUGWv')
    12. This will now log you in to your twitter account. Note that if you ever revoke the access tokens (which you are unlikely to do by accident), you will have to change the value in the access_token_key and access_token_secret parameters. At this point, your code can make any of the function calls that the ​ Twitter API module provides.
    13. To post an update to Twitter, try the following script with the keys you got from your app.
    Code:
    import twitter
    
    api = twitter.Api(consumer_key='og82uZE9GOLMDsQxileh65', consumer_secret='me7hXfqDOv0KZuHICWnpdxTNykQBoUrS1zVgb4ARFt', access_token_key='iINPSMrwktD4ZLn01WhfoRb7a2OJ6F38zKlYBTQcm5UvjgHGAe', access_token_secret='5Opjh1qMaHAyz2Bw9i4bxPKNLE0RFeJuYsn8TdtUGWv')
    
    api.PostUpdate('Voila')
    14. Log in to the twitter account you created to see the post.
    Last edited by blackbird464; 03-22-2013, 09:24 AM. Reason: installation procedure update
Working...
X