Skip to content

Instantly share code, notes, and snippets.

@hokorobi
Created November 26, 2010 13:11
Show Gist options
  • Save hokorobi/716686 to your computer and use it in GitHub Desktop.
Save hokorobi/716686 to your computer and use it in GitHub Desktop.
twitterclient.py
import os
import yaml
yaml_data = yaml.load(open(os.path.join(os.environ["USERPROFILE"],'.twitter')))
#print yaml_data
import sys
if len(sys.argv) != 2:
raw_input('needs argument.')
exit()
status = unicode(sys.argv[1], sys.stdin.encoding)
status_length = len(status)
if status_length > 140:
raw_input('too long tweet. %d' % status_length)
exit()
if status_length == 0:
exit()
import twoauth
try :
api = twoauth.api(yaml_data["token"], yaml_data["secret"], yaml_data["atoken"], yaml_data["asecret"])
api.status_update(status.encode('utf-8'))
except urllib2.HTTPError, e:
raw_input('%s.' % e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment