def shortenUrl(self, URL):
"""
URL Shortener function that when combined with the uploading
script adds a new key:value to the JSON response with a much
more managable URL.
Args:
URL: string. URL parsed from JSON response
"""
http = Authorize()
service = discovery.build('urlshortener', 'v1', http=http)
url = service.url()
body = {
'longUrl': URL
}
response = url.insert(body=body).execute()
logging.debug("URLSHRINK: %s" % response)
short_url = response['id']
logging.debug("URLSHRINK: %s" % short_url)
return short_url
评论列表
文章目录