How do I switch from using a single Twitter API account to use multiple accounts, leaving it a private application?

I made an application that publishes on my Twitter account. Currently, I have hardcoded the consumer key, consumer secret, token access key and token access secret into the system.

Now I would like to use this application for two accounts and, possibly, even more later. What values ​​need to be changed to make the same message in a different account and how to get the values? I do not see any of them at dev.twitter.com.

0
source share
1 answer

python-twitter, , , .

, , settings.py put

TWITTER_ACCOUNTS = {
    'public': {
        'consumer_key':        'PUT_C_KEY_HERE',
        'consumer_secret':     'PUT_C_SEC_HERE',
        'access_token_key':    'PUT_A_KEY_HERE',
        'access_token_secret': 'PUT_A_SEC_HERE',
     },
     'personal': {
        'consumer_key':        'PUT_C_KEY_HERE',
        'consumer_secret':     'PUT_C_SEC_HERE',
        'access_token_key':    'PUT_A_KEY_HERE',
        'access_token_secret': 'PUT_A_SEC_HERE',
     },
}

twitter api:

( ). .

https://dev.twitter.com/apps,

(, )

import twitter
from django.conf import settings

account = settings.TWITTER_ACCOUNTS['personal']
api = twitter.Api(**account)  # <----This will inject your account settings as keyword args
status = api.PostUpdate('I love python-twitter!')

, .

EDIT: , 3: http://jeffmiller.github.com/2010/05/31/twitter-from-the-command-line-in-python-using-oauth

+1

All Articles