Tweepy Print Account Status

August 26, 2011

On my brass band directory site, I wanted to show the latest tweet if the band had a twitter account.

Here's the tweepy code that gets hold of the user's latest status:

def _get_twitter_status(pTwitterAccountName):
    """
    Get hold of this twitter users's latest status
    """
    lStatus = ""
    try:
        lApi = tweepy.API()
        lUser = lApi.get_user(pTwitterAccountName)
        lStatus = lUser.timeline()[0]
    except:
        pass
    return lStatus.text

Tags: tweepy twitter status