Skip to content

Instantly share code, notes, and snippets.

@anir0y
Created November 29, 2022 10:02
Show Gist options
  • Save anir0y/8eddd0af1cedd35ae8304237452fd92e to your computer and use it in GitHub Desktop.
Save anir0y/8eddd0af1cedd35ae8304237452fd92e to your computer and use it in GitHub Desktop.
import requests
import json
headers = {
'Authorization': 'Bearer {TOKEN}',
'Content-Type': 'application/json',
}
url= input('Enter Domain(with HTTP): ')
#url = 'https://'+url
data = '{ "long_url": "' + url + '", "domain": "bit.ly", "group_guid": "{guuid}" }' # SOMETHIG LIKE this: Bl3ib2L7r8h (gourp ID)
response = requests.post('https://api-ssl.bitly.com/v4/shorten', headers=headers, data=data)
blob = response.text
person_dict = json.loads(blob)
link = (person_dict['link'])
print(f"Bitly URL is: {link}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment