标题和获取最新主题 API 的问题

您好,

我们正在使用 Discourse 论坛,并为应用程序定制了用户体验(UX)。我们利用公开的 API 与 Discourse 进行交互。我们的 UX 中没有“标题后跟内容”的概念,实际上只需要发布输入的内容。如果为了适配 Discourse 的风格,我将部分初始字符作为标题,将原始内容作为正文(raw)发布,那么在获取最新话题或话题列表时,我只能看到标题,而无法获取第一号帖子(即我的实际内容)。请问是否有解决方案或自定义方法可以解决这一问题?

1 个赞

This is what is returned by the Discourse topic lists. I don’t think the lack of a proper title is what is causing the problem. To get actual post content from a topic list, you need to make two API requests. First make an API request to get the topic list. Then from the topics that are returned, you need to get the topic ids and make a request to /t/<topic_id>.json for each topic. Substitute the id of the topic you want for <topic_id>. This second request will return the first 20 posts in the topic.

4 个赞

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.