work on more examples
This commit is contained in:
parent
b9e6374ba0
commit
e44b82c3a9
@ -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
22
examples/get_latest.py
Normal 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()
|
0
lunduke/forum/__init__.py
Normal file
0
lunduke/forum/__init__.py
Normal file
9
lunduke/forum/mappings.py
Normal file
9
lunduke/forum/mappings.py
Normal file
@ -0,0 +1,9 @@
|
||||
class Categories:
|
||||
"""Category mappings"""
|
||||
def __init__(self):
|
||||
|
||||
self.categories = {
|
||||
15: "Politics OK",
|
||||
16: "No Politics",
|
||||
23: "Forum Stuff"
|
||||
}
|
Loading…
Reference in New Issue
Block a user