work on more examples

This commit is contained in:
Greg Gauthier 2025-04-12 23:56:34 +01:00
parent b9e6374ba0
commit e44b82c3a9
4 changed files with 38 additions and 4 deletions

View File

@ -2,12 +2,15 @@ from lunduke.client import DiscourseClient
def main():
client = DiscourseClient()
categories = client.get('/categories.json').json()['category_list']
print(categories)
try:
draft_data = {
"title": "Simple forum post",
"raw": "Simple forum post content"
"title": "Testing 1 2 3",
"raw": "This is only a test",
"category": 15
}
response = client.post('/posts.json', data=draft_data)

22
examples/get_latest.py Normal file
View File

@ -0,0 +1,22 @@
from lunduke.client import DiscourseClient
def main():
client = DiscourseClient()
params = {
'order': 'created',
'ascending': 'false'
}
try:
response = client.get('/latest.json', params=params)
topics = response.json()['topic_list']['topics']
print(f"Found {len(topics)} topics")
for topic in topics:
print(topic['title'])
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
main()

View File

View File

@ -0,0 +1,9 @@
class Categories:
"""Category mappings"""
def __init__(self):
self.categories = {
15: "Politics OK",
16: "No Politics",
23: "Forum Stuff"
}