Home > Experiments, python, Uncategorized > The little twitter client I use :)

The little twitter client I use :)

Here’s a small python script to update and read tweets from different timelines. You can use it with head/tail commands to customize the output. Actually, I wrote this script just for personal use and now I would like to share it with you πŸ™‚ Thanks to tweepy python module, make sure it’s installed before trying the script πŸ™‚

#!/usr/bin/env python
# Copyright 2011 Ershad K <ershad92@[nospam]gmail.com>
# Licensed under GPL Version 3

import sys
import tweepy

CONSUMER_KEY = ' Fill here'
CONSUMER_SECRET = ' File here too'
ACCESS_KEY = ' Type yours here'
ACCESS_SECRET = 'Type yours here too'

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)

if sys.argv[1] == 'u':
    api.update_status(sys.argv[2])

elif sys.argv[1] == 'p':
    public_tweets = api.public_timeline()
    for tweet in public_tweets:
        print tweet.user.screen_name,":",tweet.text
        print ""

elif sys.argv[1] == 'r':
    mention_tweets = api.mentions()
    for mtweet in mention_tweets:
        print mtweet.user.screen_name,":",mtweet.text
        print ""

elif sys.argv[1] == 'h':
    friends_tweets = api.home_timeline()
    for ftweet in friends_tweets:
        print ftweet.user.screen_name,":", ftweet.text
        print ""

Hope you like it πŸ™‚

Advertisements
  1. August 29, 2011 at 11:28 pm

    Thanks for sharing. I just started to work with tweepy and this helped me a lot. πŸ™‚
    Actually I’m working on a client with a GUI using wxpython.

    • August 30, 2011 at 10:31 am

      I’m happy that it helped you. All the best with GUI client πŸ™‚

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: