Login

automating twitter

Author:
lawgon
Posted:
July 1, 2009
Language:
Python
Version:
1.0
Tags:
twitter
Score:
2 (after 2 ratings)

Assume you have a model called Delegate and you want to tweet whenever a new Delegate registers, the code above will do this. You need to install python-twitter.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
import twitter
from django.db.models.signals import post_save

def tweetit(sender,**kwargs):
    """
        extract relevant info and tweet it
        """
    if kwargs['created']:
        t = twitter.Api(settings.TWITTER_USER, settings.TWITTER_PASSWORD)
        t.PostUpdate("%s has registered as a delegate" %(kwargs['instance']))
    
post_save.connect(tweetit, sender=Delegate)

More like this

  1. twitterize filter by thomasw 6 years, 1 month ago
  2. Twitter oAuth example by henriklied 6 years, 2 months ago
  3. App-specific delegation of template context processors by oogles 1 year, 3 months ago
  4. twitter_status by zodman 6 years, 8 months ago
  5. Django Twitter Bootstrap 3 pagination by Ragnar_Lodbrok 1 year, 3 months ago

Comments

Please login first before commenting.