I have a python program and a WordPress site and I want to enter the information that the Telegram bot receives to the site. I'm using Jet engine plugin and I don't know how to send data from the python program and receive it on the site. Here is my sample code for sending data:
import requests
import json
# Define the URL
url = 'http://example.com/wp-json/wp/v2/posts' # Adjusted for posts endpoint, ensure it matches your need
# Your WordPress username
username = 'your_username'
# Your Application Password
password = 'your_application_password'
# Prepare your JSON data (example here is for creating a new post, adjust as necessary)
data = {
"title": "Hello World",
"content": "This is the content of my post.",
"status": "publish"
}
# Convert data to JSON format
json_data = json.dumps(data)
# Set headers to specify JSON content
headers = {'Content-Type': 'application/json'}
# Send POST request with JSON data and Basic Auth for authentication
response = requests.post(url, data=json_data, headers=headers, auth=(username, password))
print(response.status_code)