Twitteran di konsole !
#1
Malam all !!
Lama nda pernah buat postingan lagi di forum yang makiiiinn keren ini !! ekekek
kali ini mau share dikit script sederhana sy, yg sering sy pake untuk twitteran di konsolenya si back|track. biar lebih kerenn, lebih sangar klo mainnya di konsole !!! hihiiihii

tapi yg pastinya beda antara twitteran di browser n di konsole pasti lebih cepat klo mainnya di konsole !!!

ok langsung aja !!! yang dibutuhkan untuk mendukung tool ini adalah library python-twitter yang bisa di download di sini ..
cara installnya :
-- extract file nya
-- cd nama folder hasil extract
-- python setup.py build
-- python setup.py install
-- ok

yang harus di persiapkan lagi adalah costumer_key, costumer_secret, access_token, access_token_secret ... yang bisa didapatkan dengan membuat apps di twtitter. jadi langsung aja buat appsnya disini. appsnya sembarang sajalah !! berikut langkah2 nya :
-- browse link diatas
-- klo diminta login, yahh login lah !
-- click "Create a new aplication"
-- isikan data Aolication anda, lalu click "Create my aplication"
-- Jika sukses, maka anda akan tiba di page APP anda, perhatikan anda telah mendapatkan costumer key n costumer key secret, tapi Access Levelnya "Read-Only".
-- click "create my access token", jika sudah sekarang kita perlu meningkatkan privileage APP kita.
-- click tab setting, scroll ke bawah sampai pada Application Type, pilih Read, Write and Access direct messages
-- click "update this Twitter application settings"
-- kembali ke tab Details, lalu click "recreate my access token", dapat deh access token dengan privileage yang R/W.

udah itu aja kok langkah2 yg di perlukan. simple kan ... hihiihihh
dari langkah diatas kita udah dapatkan costumer_key, costumer_secret, access_token, access_token_secret...

masukkan ke sctipnya yah !

[shcode=python]
import twitter
import sys
import time
import os

costumer_key = 'sesuaikan dengan key anda n tetap pake tanda petik'
costumer_secret = 'sesuaikan dengan key anda n tetap pake tanda petik'
access_token = 'sesuaikan dengan key anda n tetap pake tanda petik'
access_token_secret = 'sesuaikan dengan key anda n tetap pake tanda petik'

#example
#costumer_key = 'NQMPxdgVMAJGe1b2g3h4j'
#costumer_secret = 'WhBNeJaeWG4eypSclU2tVbIGdkeoo41b2g3f4h5f'
#access_token = '126010565-2q4e9njh7dblYNmpEm3hQ1lbT1M17NwaSAgEvrr'
#access_token_secret = '2q4e9njh7dbHO004GPv2f9OqA97FRw3DxaX5BET4A'

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
[email protected]
http://khairil12.blogspot.com


[1] Tweet something
[2] Show your following list
[3] Show your past tweet
[4] Show the newest tweet
[5] Show tweets who mention you
[6] Follow someone
[X] X for Exit

\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 == '6':
try:
follow = raw_input('[>] Please input a username that will follow : ')
print '[>] Please waiting ... \n'
api.CreateFriendship(follow)
print '[>] You have following >> %s !"' %(follow)
except:
print '[>] There\'s something wrong, bro !! failed to follow !'
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.GetFriendsTimeline()
for i in friends:
print '''==================================
by RR12
Username : %s
Tweet : %s
Created at : %s

''' %(i.user.name, i.text, i.relative_created_at)
time.sleep(2)

except:
print '[>] There\'s something wrong, bro !! failed to show lastest tweet !'
sys.exit('[>] Exit !')

elif option == '5':
try:
print '[>] Please waiting ... \n'
mentions = api.GetReplies()
for i in mentions:
print '''==================================
by RR12
Username : %s
Created at : %s
Tweet : %s

''' %(i.user.name, i.created_at, i.text)
time.sleep(2)
except:
print '[>] There\'s something wrong, bro !! failed to show your post replies (MENTIONS) !'
sys.exit('[>] Exit !')

elif option in ('X', 'x', 'Exit', 'exit'):
sys.exit('\n[+] Thank you, bro !! \n\n[*]Exit')

else:
sys.exit('\n[*] Wrong choice, 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 ? ')

sys.exit('\n[+] Thank you, bro !! \n\n[*]Exit')
[/shcode]


jadi yg bisa kita lakukan dengan script ini adalah :
[1] tweet/ update status
[2] menampilkan daftar teman/ orang yg kita follow
[3] melihat tweet kita yg terdahulu
[4] menampilkan status terbaru dari teman kita
[5] menampilkan status yg me-mention anda
[6] follow orang lain berdasarkan username ex:idbacktrack

SS, sy menampilkan status terbaru :
[Image: zn5zpy.jpg]

SS, sy coba follow twitternya IBT :
[Image: r2nhvn.jpg]

Ok. itu aja mungkin yahh untuk om2 ganteng semua yg selalu ngeramein forum tercinta ini !!! heheh
sory klo mungkin ada step2 yg kurang jelas, mari didiskusikan disini.. klo ada yang mau mengembangkan silahkan, sy juga masih mau nambah beberapa lagi.. masih cupu sehh toolnya !
:apn:

Thanks . Smile

#2
Makin gila aja nih om RR12!!!!
Yang putih, yang seharusnya ber-aksi dan berbakat!
Linuxtivist blog

#3
wew.... wah langsung ijin uji coba nih Big Grin

#4
(11-11-2011, 11:36 PM)THJC Wrote: ntar munculnya via apa om?

maksudnya via kek gmana ??
via2 yg kyk di FB gitu maksudnya ?? gug ada via2an kyknya om !! hehe kan
ini SSnya sy buat tweet baru !

[Image: a9vin6.jpg]
(11-11-2011, 11:37 PM)konspirasi Wrote: wew.... wah langsung ijin uji coba nih Big Grin

monggo om !!! thanks dah mau di cobain !!

#5
om, saya rada bingung...

pas di
Quote:masukkan ke sctipnya yah !

Itu file apa?
Yang putih, yang seharusnya ber-aksi dan berbakat!
Linuxtivist blog

#6
(11-12-2011, 12:06 AM)THJC Wrote: om, saya rada bingung...

pas di
Quote:masukkan ke sctipnya yah !

Itu file apa?

bukan file om !! tapi yg costumer key, costumer key secret, access token, access token secret, yg om dapat dari APP yg dibuat ditwitter di masukkan ke scriptnya !!

di bagian ini om ! Smile

Code:
costumer_key = 'sesuaikan dengan key anda n tetap pake tanda petik'
costumer_secret = 'sesuaikan dengan key anda n tetap pake tanda petik'
access_token = 'sesuaikan dengan key anda n tetap pake tanda petik'
access_token_secret = 'sesuaikan dengan key anda n tetap pake tanda petik'

#example
#costumer_key = 'NQMPxdgVMAJGe1b2g3h4j'
#costumer_secret = 'WhBNeJaeWG4eypSclU2tVbIGdkeoo41b2g3f4h5f'
#access_token = '126010565-2q4e9njh7dblYNmpEm3hQ1lbT1M17NwaSAgEvrr'
#access_token_secret = '2q4e9njh7dbHO004GPv2f9OqA97FRw3DxaX5BET4A'

sorry yahh kalo step yg diatas membingungkan !!! T_T

#7
(11-12-2011, 12:44 AM)RR12 Wrote:
(11-12-2011, 12:06 AM)THJC Wrote: om, saya rada bingung...

pas di
Quote:masukkan ke sctipnya yah !

Itu file apa?

bukan file om !! tapi yg costumer key, costumer key secret, access token, access token secret, yg om dapat dari APP yg dibuat ditwitter di masukkan ke scriptnya !!

di bagian ini om ! Smile

Code:
costumer_key = 'sesuaikan dengan key anda n tetap pake tanda petik'
costumer_secret = 'sesuaikan dengan key anda n tetap pake tanda petik'
access_token = 'sesuaikan dengan key anda n tetap pake tanda petik'
access_token_secret = 'sesuaikan dengan key anda n tetap pake tanda petik'

#example
#costumer_key = 'NQMPxdgVMAJGe1b2g3h4j'
#costumer_secret = 'WhBNeJaeWG4eypSclU2tVbIGdkeoo41b2g3f4h5f'
#access_token = '126010565-2q4e9njh7dblYNmpEm3hQ1lbT1M17NwaSAgEvrr'
#access_token_secret = '2q4e9njh7dbHO004GPv2f9OqA97FRw3DxaX5BET4A'

sorry yahh kalo step yg diatas membingungkan !!! T_T

scriptnya yg mana om? bingung juga nih..

#8
@nyelonong
wadduuuhh itu kan scriptnya ada diatas om !! ehehehhe
ini loh ..

Code:
import twitter
import sys
import time
import os

costumer_key = 'sesuaikan dengan key anda n tetap pake tanda petik'
costumer_secret = 'sesuaikan dengan key anda n tetap pake tanda petik'
access_token = 'sesuaikan dengan key anda n tetap pake tanda petik'
access_token_secret = 'sesuaikan dengan key anda n tetap pake tanda petik'

#example
#costumer_key = 'NQMPxdgVMAJGe1b2g3h4j'
#costumer_secret = 'WhBNeJaeWG4eypSclU2tVbIGdkeoo41b2g3f4h5f'
#access_token = '126010565-2q4e9njh7dblYNmpEm3hQ1lbT1M17NwaSAgEvrr'
#access_token_secret = '2q4e9njh7dbHO004GPv2f9OqA97FRw3DxaX5BET4A'

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
                                   [email protected]
                                   http://khairil12.blogspot.com
                                

[1] Tweet something
[2] Show your following list
[3] Show your past tweet
[4] Show the newest tweet
[5] Show tweets who mention you
[6] Follow someone
[X] X for Exit

\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 == '6':
        try:
        follow = raw_input('[>] Please input a username that will follow : ')
        print '[>] Please waiting ... \n'
        api.CreateFriendship(follow)
        print '[>] You have following >> %s !"' %(follow)
        except:
        print '[>] There\'s something wrong, bro !! failed to follow !'
        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.GetFriendsTimeline()
        for i in friends:
                print '''==================================
          by RR12            
Username       : %s
Tweet        : %s
Created at    : %s
            
                ''' %(i.user.name, i.text, i.relative_created_at)
            time.sleep(2)
            
        except:
        print '[>] There\'s something wrong, bro !! failed to show lastest tweet !'
        sys.exit('[>] Exit !')
    
    elif option == '5':
        try:
        print '[>] Please waiting ... \n'
        mentions = api.GetReplies()
        for i in mentions:
            print '''==================================
          by RR12            
Username       : %s
Created at    : %s
Tweet        : %s
            
            ''' %(i.user.name, i.created_at, i.text)
            time.sleep(2)
        except:
        print '[>] There\'s something wrong, bro !! failed to show your post replies (MENTIONS) !'
        sys.exit('[>] Exit !')
    
    elif option in ('X', 'x', 'Exit', 'exit'):
        sys.exit('\n[+] Thank you, bro !! \n\n[*]Exit')    
        
    else:
        sys.exit('\n[*] Wrong choice, 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 ? ')
    
    sys.exit('\n[+] Thank you, bro !! \n\n[*]Exit')


#9
iya om, saya mengerti..
Maksudnya...

di folder
python-twitter-0.8.2 itu ada banyak file kan?
File mana yang harus di edit?
Yang putih, yang seharusnya ber-aksi dan berbakat!
Linuxtivist blog

#10
(11-12-2011, 01:25 AM)THJC Wrote: iya om, saya mengerti..
Maksudnya...

di folder
python-twitter-0.8.2 itu ada banyak file kan?
File mana yang harus di edit?

gug ada yg perlu di edit di python-twitter nya om !! itu diinstall aja !!

yg diedit cukup di bagian script saya !! edit sesuaikan dengan costumer key, dll yg om udah dapet dari twitter !!!






Users browsing this thread: 1 Guest(s)