If you are using the Xenforo community forum script and starting to learn the Xenforo Rest API. This post is to show you how you can programmatically reply to threads with a simple Python script.
Code:
# Xenforo Forum - Programmatic Post to Thread
import requests
# Send API header request
headers = {
'Content-type' : 'application/x-www-form-urlencoded',
'XF-Api-User': '1',
'XF-Api-Key' : 'api-key-goes-here'
}
# Connect with the API Endpoint
url = 'https://example.com/api/posts/'
# Post data contents
data = {
'thread_id': 950,
'message': 'Message contents goes in here.'
}
r = requests.post(url, headers=headers, data=data)
# Print the response (200 is success)
print(r)