Skip to content

Commit

Permalink
Adding example.py for easy understanding of libturpial use
Browse files Browse the repository at this point in the history
  • Loading branch information
guerrerocarlos committed Dec 31, 2012
1 parent da21a66 commit 393ee74
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from libturpial.api.core import Core

#Put here your twitter account username
account = '@example'

#This example is for a twitter account
service_account = account+'-twitter'

core = Core()
core.register_account(account, 'twitter')
response = core.login(service_account)

if response.code > 0:
raise Exception

auth_obj = response.items

# Validates if account needs authorization
if auth_obj.must_auth():
print "Visit %s, authorize Turpial and write back the pin" % auth_obj.url
pin = raw_input('Pin: ')
core.authorize_oauth_token(service_account, pin)

data = core.auth()
core.send_direct(service_account,'@guerrerocarlos',"testing!")
#core.broadcast_status([service_account],"123 testing from libturpial')

0 comments on commit 393ee74

Please sign in to comment.