We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2b6507e commit 2aa187eCopy full SHA for 2aa187e
services/bitly.py
@@ -59,6 +59,17 @@ def expand(self, tinyurl):
59
raise ShortyError(jdata['errorMessage'])
60
return str(jdata['results'].values()[0]['longUrl'])
61
62
+ def stats(self, tinyurl):
63
+ if not self.login:
64
+ return get_redirect(tinyurl)
65
+ parameters, username_pass = self._setup()
66
+ parameters['shortUrl'] = tinyurl
67
+ resp = request('http://api.bit.ly/v3/clicks', parameters, username_pass)
68
+ jdata = json.loads(resp.read())
69
+ if jdata['status_code'] != 200:
70
+ raise ShortyError(jdata['errorMessage'])
71
+ return str(jdata['data']['clicks'][0]['global_clicks'])
72
+
73
def qrcode(self, tinyurl):
74
qrdata = request(tinyurl + '.qrcode').read()
75
return qrdata
0 commit comments