2025-04-11 21:46:02 +00:00
|
|
|
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)
|
|
|
|
|
|
|
|
# Use the client
|
|
|
|
try:
|
|
|
|
response = client.get('/posts.json')
|
|
|
|
posts = response['latest_posts']
|
|
|
|
print(f"Found {len(posts)} posts")
|
|
|
|
for post in posts:
|
2025-04-12 16:30:44 +00:00
|
|
|
# print(post)
|
|
|
|
print(post['username'], post['topic_title'], post['excerpt'])
|
2025-04-11 21:46:02 +00:00
|
|
|
except Exception as e:
|
|
|
|
print(f"Error: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|