Last active
December 18, 2015 21:29
-
-
Save guerrerocarlos/5847616 to your computer and use it in GitHub Desktop.
Ejemplo sencillo de envío de un mensaje utilizando Libturpial. Incluye registro de la cuenta
This file contains hidden or 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
# -*- coding=utf-8 -*- | |
from libturpial.api.models.account import Account | |
from libturpial.api.core import Core | |
c = Core() | |
cuenta = "guerrerocarlos-twitter" | |
mensaje = "Probando desde libturpial" | |
cuentas_registradas = c.list_accounts() | |
print "Cuentas registradas: ",cuentas_registradas,"\n" | |
if cuenta in cuentas_registradas: | |
print "Cargando cuenta",cuenta,"\n" | |
print c.update_status("guerrerocarlos-twitter","Probando desde libturpial") | |
else: | |
a = Account.new('twitter') | |
url = a.request_oauth_access() | |
print "Por favor Acceda a la URL, inicie sesión y escriba a continuación el PIN:" | |
print url | |
cod = raw_input("PIN:") | |
a.authorize_oauth_access(cod) | |
c.register_account(a) |
Listo :)
Gracias @satanas
@guerrerocarlos De nada mi pana. La línea 14 podría quedar incluso así:
print c.update_status(cuenta, "Probando desde libturpial")
Saludos ;)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bro, no hace falta que cargues la cuenta si ya fue registrada (línea 12), al instanciar Core él se encarga de eso. En la línea 15 podrías hacer:
c.update_status('guerrerocarlos-twitter', 'mensaje')
Con eso sería suficiente :)