forked from satanas/libturpial
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding example.py for easy understanding of libturpial use
- Loading branch information
1 parent
da21a66
commit 393ee74
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |