Created
November 19, 2010 20:24
-
-
Save dsmith/707098 to your computer and use it in GitHub Desktop.
Maybe...?
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
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