From: Josh Roesslein Date: Fri, 7 Aug 2009 17:11:40 +0000 (-0500) Subject: Added trends api endpoint to api. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=8f9c662e9f52320f9073612e574e543a5603d025;p=tweepy.git Added trends api endpoint to api. --- diff --git a/tweepy/api.py b/tweepy/api.py index c72e2e1..341dcc2 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -374,3 +374,10 @@ class API(object): allowed_param = ['q', 'lang', 'rpp', 'page', 'since_id', 'geocode', 'show_user'], )(self, *args, **kargs) + def trends(self): + return bind_api( + host = 'search.' + self.host, + path = '/trends.json', + parser = parse_trend_results + )(self) + diff --git a/tweepy/parsers.py b/tweepy/parsers.py index f7704e8..fe10bc5 100644 --- a/tweepy/parsers.py +++ b/tweepy/parsers.py @@ -9,6 +9,18 @@ try: except ImportError: import simplejson as json +def parse_json(data, api): + + return json.loads(data) + +def parse_return_true(data, api): + + return True + +def parse_none(data, api): + + return None + def parse_error(data): return json.loads(data)['error'] @@ -161,14 +173,8 @@ def parse_search_results(data, api): result_objects.append(_parse_search_result(obj, api)) return result_objects -def parse_json(data, api): - - return json.loads(data) - -def parse_return_true(data, api): +def parse_trend_results(data, api): - return True + return json.loads(data)['trends'] + -def parse_none(data, api): - - return None