Seemingly the bit.ly API has been updated a lot in recent years. Here is the website of the latest API documentation https://dev.bitly.com/api-reference
I am trying to do the simplest operation, i.e., shortening a long URL. I have generated a token following the instructions, and below is the code I tried following the example (https://dev.bitly.com/api-reference/#createBitlink) where I used my token instead of the string "my token" here:
import requests
headers = {
"Authorization": "Bearer {my token}",
"Content-Type": "application/json",
}
data = '{ "long_url": "https://dev.bitly.com", "domain": "bit.ly"}'
response = requests.post(
"https://api-ssl.bitly.com/v4/shorten", headers=headers, data=data
)
But the response is 403. Is there anyone who is familiar with the bit.ly API? Any help will be appreciated!
A related question: getting bit.ly to return shortened URL
Sorry for the confusion... It is seemingly okay now. Below is an example extended from https://dev.bitly.com/api-reference/#createBitlink