Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updating link endpoints

  • Loading branch information...
commit 97f1d05c68edfb6bb1cfd4b2f16329ab98bfc8ff 1 parent 337b450
Hilary Mason authored
Showing with 18 additions and 2 deletions.
  1. +18 −2 bitly_api/bitly_api.py
View
20 bitly_api/bitly_api.py
@@ -63,11 +63,15 @@ def shorten(self, uri, x_login=None, x_apiKey=None, preferred_domain=None):
data = self._call(self.host, 'v3/shorten', params, self.secret)
return data['data']
- def expand(self, hash=None, shortUrl=None):
+ def expand(self, hash=None, shortUrl=None, link=None):
""" given a bitly url or hash, decode it and return the target url
@parameter hash: one or more bitly hashes
@parameter shortUrl: one or more bitly short urls
+ @parameter link: one or more bitly short urls (preferred vocabulary)
"""
+ if link and not shortUrl:
+ shortUrl = link
+
if not hash and not shortUrl:
raise BitlyError(500, 'MISSING_ARG_SHORTURL')
params = dict()
@@ -202,8 +206,11 @@ def user_link_history(self, created_before=None, created_after=None, archived=No
data = self._call_oauth2("v3/user/link_history", params)
return data["link_history"]
- def info(self, hash=None, shortUrl=None):
+ def info(self, hash=None, shortUrl=None, link=None):
""" return the page title for a given bitly link """
+ if link and not shortUrl:
+ shortUrl = link
+
if not hash and not shortUrl:
raise BitlyError(500, 'MISSING_ARG_SHORTURL')
params = dict()
@@ -215,8 +222,17 @@ def info(self, hash=None, shortUrl=None):
data = self._call(self.host, 'v3/info', params, self.secret)
return data['data']['info']
+ def link_lookup(self, url): #TODO: test with SSL
+ """ query for a bitly link based on a long url (or list of long urls)"""
+ params = dict(url=url)
+ data = self._call(self.host, 'v3/link/lookup', params, self.secret)
+ return data
+
+
def lookup(self, url):
""" query for a bitly link based on a long url """
+ warnings.warn("/v3/lookup is depricated in favor of /v3/link/lookup", DeprecationWarning)
+
params = dict(url=url)
data = self._call(self.host, 'v3/lookup', params, self.secret)
Please sign in to comment.
Something went wrong with that request. Please try again.