Skip to content

Instantly share code, notes, and snippets.

@dsmith
Created November 19, 2010 20:24
Show Gist options
  • Save dsmith/707098 to your computer and use it in GitHub Desktop.
Save dsmith/707098 to your computer and use it in GitHub Desktop.
Maybe...?
class Twitter(object):
def __init__(self, consumer, token=None, url='http://api.twitter.com/1', name='', **kwargs):
self.client, self.url = oauth.Client(consumer, token), '%s/%s.json' % (url, name)
__getattr__ = lambda self, name: Twitter(self.consumer, self.token, url=self.url, name=name)
def __call__(self, **kwargs):
return json.loads(filter(lambda x: x['status'] == '200' or not x.has_key('status'), self.client.request((self.url, urllib.urlencode(kwargs)), "GET"))[1])
raise Exception('Invalid response.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment