'Initialize Twitter API'

@staticmethod
def get_twitter_api(channel_id=None):

    try:
        import tweepy
    except ImportError:
        current.log.error('s3msg', 'Tweepy    not    available,    so    non-Tropo    Twitter    support    disabled')
        return None
    table = current.s3db.msg_twitter_channel
    if (not channel_id):
        query = (table.enabled == True)
        limitby = None
    else:
        query = (table.channel_id == channel_id)
        limitby = (0, 1)
    rows = current.db(query).select(table.login, table.twitter_account, table.consumer_key, table.consumer_secret, table.access_token, table.access_token_secret, limitby=limitby)
    if (len(rows) == 1):
        c = rows.first()
    elif (not len(rows)):
        current.log.error('s3msg', 'No    Twitter    channels    configured')
        return None
    else:
        rows.exclude((lambda row: (row.login != True)))
        if (len(rows) == 1):
            c = rows.first()
        elif (not len(rows)):
            current.log.error('s3msg', 'No    Twitter    channels    configured    for    login')
            return None
    if (not c.consumer_key):
        current.log.error('s3msg', 'Twitter    channel    has    no    consumer    key')
        return None
    try:
        oauth = tweepy.OAuthHandler(c.consumer_key, c.consumer_secret)
        oauth.set_access_token(c.access_token, c.access_token_secret)
        twitter_api = tweepy.API(oauth)
        return (twitter_api, c.twitter_account)
    except:
        return None
