# Basic API example for CREATING a paste.
import requests
TOKEN = "XZH91r8PJnuBqFKAgw1HBKv9ESlHC_5cFY8no7F7lJbtrLI_TSxF3V9hns2HHgYhU34cS5SllTnLaWZ7lLITRg"
MESSAGE = '''Your text link, ..., [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) is \n also *supported*.'''
try:
response = requests.post("https://paster.so/api/v2/publishers/pastes/markdown/create", headers = {"Content-Type": "application/json","Authorization": TOKEN}, json={"content": MESSAGE,"title": "🎁"})
response_data = response.json()
if "paste" in response_data and "url" in response_data["paste"]:
paste_url = response_data["paste"]["url"]
print(paste_url)
else:
print("Response did not contain a URL:", response_data)
except requests.exceptions.RequestException as e:
print("Error making the request:", e)
Comments
Post a Comment