34 lines
823 B
Python
34 lines
823 B
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)
|
||
|
|
||
|
# Use the client
|
||
|
try:
|
||
|
response = client.get('/posts.json')
|
||
|
posts = response['latest_posts']
|
||
|
print(f"Found {len(posts)} posts")
|
||
|
for post in posts:
|
||
|
print(post['post_type'], post['username'], post['topic_id'])
|
||
|
except Exception as e:
|
||
|
print(f"Error: {e}")
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
main()
|