47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
|
from lunduke.config import DiscourseConfig
|
||
|
from lunduke.auth import DiscourseAuth
|
||
|
from lunduke.client import DiscourseClient
|
||
|
|
||
|
|
||
|
def main():
|
||
|
# Set up configuration
|
||
|
config = DiscourseConfig(
|
||
|
host='forum.lunduke.com',
|
||
|
username='gmgauthier'
|
||
|
)
|
||
|
|
||
|
# Set up authentication
|
||
|
auth = DiscourseAuth(
|
||
|
api_key_file='../keys/cli_key.txt',
|
||
|
username=config.username
|
||
|
)
|
||
|
|
||
|
# Create client
|
||
|
client = DiscourseClient(config, auth)
|
||
|
|
||
|
# Create a draft post
|
||
|
try:
|
||
|
|
||
|
draft_data = {
|
||
|
"title": "Simple forum post",
|
||
|
"raw": "Simple forum post content"
|
||
|
}
|
||
|
|
||
|
# draft_data = {
|
||
|
# "draft_key": "new_topic",
|
||
|
# "data": {
|
||
|
# "title": "Test Draft Topic from API",
|
||
|
# "raw": "This is the content of my draft post created via the API.",
|
||
|
# "category_id": 1 # Replace with your desired category ID
|
||
|
# }
|
||
|
# }
|
||
|
|
||
|
response = client.post('/posts.json', data=draft_data)
|
||
|
print(f"Draft created successfully: {response}")
|
||
|
|
||
|
except Exception as e:
|
||
|
print(f"Error creating draft: {e}")
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
main()
|