Example: Posting a paragraph-length tweet (threaded if necessary)
import requests
url = "https://api.twitter.com/2/tweets"
headers = {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "application/json"
}
data = {
"text": "Here is a paragraph-length microblog post. If it's too long, Twitter threads can be used!"
}
response = requests.post(url, headers=headers, json=data)
print(response.json())