Twitter Client Apps !


pagiiiiiiiiiii !!!
yah langsung saja !!
disini sy mau share script sederhana yg baru sy buat !! hihihi

tentang twitter client app !!
jadi yg bisa dilakukan adalah !!
1. tweet /update status
2. memperlihatkan daftar teman / org yg kita follow !
3. menampilkan tweet kita yg dulu2
4. menampilkan tweet terbaru dari semua teman !!

yang dibuthkan untuk menjalankan nya !!!
a. python-twitter untuk module/lib nya !! bisa di donlod disini
http://code.google.com/p/python-twitter/
b. dapatkan costumer_key, costumer_scecret_key, access_token, access_scecret_token yang bisa didapatkan saat kita membuat applikasi di twitter ! untuk membuat app nya silahkan kesini ! https://dev.twitter.com/apps

klo sudah silahkan gunakan script sederhana sy ini !

import twitter
import sys
import time
import os

costumer_key = #isi dengan costumer key punya anda
costumer_secret = #isi dengan costumer secret key anda
access_token = #isi dengan access token anda
access_token_secret = #isi dengan access token secret anda

api = twitter.Api(consumer_key=costumer_key,consumer_secret=costumer_secret, access_token_key=access_token, access_token_secret=access_token_secret)

def starter():
    if os.name == 'posix':
        os.system('clear')
    else:
        os.system('cls')
    info = '''
 _            _ _   _           
| |___      _(_) |_| |_ ___ _ __
| __\ \ /\ / / | __| __/ _ \ '__|
| |_ \ V  V /| | |_| ||  __/ |  
 \__| \_/\_/ |_|\__|\__\___|_|     Client Apps
                                   by RR12
                                   u5h4nt@gmail.com
                                   http://khairil12.blogspot.com
                                

[1] Tweet something
[2] Show your following list
[3] Show your past tweet
[4] Show your friend newest tweet

\n
'''
    for i in info:
        print '\b%s' %(i),
        sys.stdout.flush()
        time.sleep(0.005)

    choice = raw_input('[>] Please input your choice : ')
    main(choice)

def main(option=None):
    if option == '1':
        try:
        status_update = raw_input('[>] What\'s happening? ')
        print '[>] Please waiting ... \n'
        api.PostUpdate(status_update)
        print '[>] Your tweet has benn updated >> \"%s\"' %(status_update)
        except:
        print '[>] There\'s something wrong, bro !! failed to tweet !'
        sys.exit('[>] Exit !')
    elif option == '2':
        try:
        print '[>] Please waiting ... \n'
        friends = api.GetFriends()
        for i in friends:
            print '''==================================
          by RR12            
ID           : %s
Name         : %s
Location     : %s
Created at   : %s
Description  : %s
           
            ''' %(i.id, i.name, i.location, i.created_at, i.description)
            time.sleep(2)
        except:
        print '[>] There\'s something wrong, bro !! failed to show the friend list !'
        sys.exit('[>] Exit !')

    elif option == '3':
        try:
            print '[>] Please waiting ... \n'
            past_tweet = api.GetUserTimeline()
            for i in past_tweet:
            print '''==================================
          by RR12            
Created at   : %s
Tweet        : %s
           
                ''' %(i.created_at, i.text)
            time.sleep(2)
        except:
        print '[>] There\'s something wrong, bro !! failed to show your tweet !'
        sys.exit('[>] Exit !')
       
    elif option == '4':
        try:
        print '[>] Please waiting ... \n'
        friends = api.GetFriends()
        for i in friends:
            last_tweet = api.GetUserTimeline(i.screen_name)
            for u in last_tweet:
                print '''==================================
          by RR12            
Username       : %s
Lastest Tweet    : %s
Created at    : %s
           
                ''' %(i.screen_name, u.text, u.created_at)
            break
           
        except:
        print '[>] There\'s something wrong, bro !! failed to show lastest tweet !'
        sys.exit('[>] Exit !')
   
    else:
        sys.exit('\n[+] Thank you, bro !! \n \n [*]Exit')
   

if __name__=='__main__':
    lagi = 'y'
    while lagi in ('y','Y','Yes', 'YES'):
        starter()
    lagi = raw_input('[>] Do you want to user this app again ? ')


itu aja kok code nya !! screen sOOt nya ini !!

Komentar

Posting Komentar

NO SPAM HERE !!!! OK GUYS !!

Postingan Populer