Last active
December 3, 2022 06:08
-
-
Save AtsushiSakai/4d29bc51194b280401907e85f73e888f to your computer and use it in GitHub Desktop.
Revisions
-
AtsushiSakai revised this gist
Dec 3, 2022 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,10 @@ # # Get access_token from: https://app.bitly.com/settings/api/ # Then, just call this function with your long url and access token # # Ref # - https://dev.bitly.com/api-reference/#createBitlink # - https://dev.bitly.com/docs/getting-started/introduction/ import requests -
AtsushiSakai renamed this gist
Dec 3, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
AtsushiSakai created this gist
Dec 3, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ # # Get access_token from: https://app.bitly.com/settings/api/ # Then, just call this function with your long url and access token import requests def get_shorten_url(long_url, access_token): url = 'https://api-ssl.bitly.com/v4/shorten' headers = {"Authorization": f"Bearer {access_token}", "Content-Type": "application/json" } body = {'long_url':long_url} res = requests.post(url, headers=headers, json=body).json() return res["link"] # shorten url