def shorten(self, ctx, url):
"""Shorten url"""
key = self.loadapi["ApiKey"]
shorten = 'https://www.googleapis.com/urlshortener/v1/url?key=' + key
payload = {"longUrl": url}
headers = {'content-type': 'application/json'}
async with aiohttp.ClientSession() as session:
async with session.post(shorten,data=json.dumps(payload),headers=headers) as resp:
print(resp.status)
yes = await resp.json()
await self.bot.say(yes['id'])
评论列表
文章目录