Skip to content
This repository has been archived by the owner on Apr 9, 2021. It is now read-only.

Commit

Permalink
Added all the Data APIs except search. Must consider how best to impl…
Browse files Browse the repository at this point in the history
…ement search.
  • Loading branch information
Brian Eoff committed Dec 21, 2012
1 parent 6b495e7 commit 56a54b4
Showing 1 changed file with 55 additions and 3 deletions.
58 changes: 55 additions & 3 deletions bitly_api/bitly_api.py
Expand Up @@ -237,6 +237,61 @@ def pro_domain(self, domain):
data = self._call(self.host, end_point, params, self.secret)
return data['data']['bitly_pro_domain']

def highvalue(self, limit=10, lang='en'):
params = dict(lang=lang)
data = self._call_oauth2_metrics("v3/highvalue", params, limit=limit)
return data

def realtime_bursting_phrases(self):
data = self._call_oauth2_metrics("v3/realtime/bursting_phrases", dict())
return data["phrases"]

def realtime_hot_phrases(self):
data = self._call_oauth2_metrics("v3/realtime/hot_phrases", dict())
return data["phrases"]

def realtime_clickrate(self, phrase):
params = dict(phrase=phrase)
data = self._call_oauth2_metrics("v3/realtime/clickrate", params)
return data["rate"]

def link_info(self, link):
params = dict(link=link)
data = self._call_oauth2_metrics("v3/link/info", params)
return data

def link_content(self, link, content_type="html"):
params = dict(link=link, content_type=content_type)
data = self._call_oauth2_metrics("v3/link/content", params)
return data["content"]

def link_category(self, link):
params = dict(link=link)
data = self._call_oauth2_metrics("v3/link/category", params)
return data["categories"]

def link_social(self, link):
params = dict(link=link)
data = self._call_oauth2_metrics("v3/link/social", params)
return data["social_scores"]

def link_location(self, link):
params = dict(link=link)
data = self._call_oauth2_metrics("v3/link/location", params)
return data["locations"]

def link_language(self, link):
params = dict(link=link)
data = self._call_oauth2_metrics("v3/link/language", params)
return data["languages"]

#TODO - Incomplete
def search(self, query, offset=None, cities=None, domain=None, fields=None, limit=10, lang='en'):
params = dict(query=query, offset=offset, cities=cities, domain=domain,
fields=fields, lang=lang)
data = self._call_oauth2_metrics("v3/search", params, limit=limit)
return data['results']

@classmethod
def _generateSignature(self, params, secret):
if not params or not secret:
Expand Down Expand Up @@ -318,8 +373,6 @@ def _call(self, host, method, params, secret=None, timeout=5000):
'params': urllib.urlencode(params, doseq=1)
}

print request

try:
http_response = bitly_http.get(request, timeout, user_agent = self.user_agent)
if http_response['http_status_code'] != 200:
Expand All @@ -334,4 +387,3 @@ def _call(self, host, method, params, secret=None, timeout=5000):
raise
except Exception:
raise BitlyError(None, sys.exc_info()[1])

0 comments on commit 56a54b4

Please sign in to comment.