如何将主题或通知标记为“已读 = true"

我正在使用 Discourse API。
我工作的网站从 Discourse API 获取所有数据。我遇到的问题是,由于我实际上并没有查看主题和通知,而是仅通过 API 获取数据,因此我的主题和通知未被标记为已读。

我该如何解决这个问题?

If I’m following, you need to make an API call to this endpoint:

3 个赞

Thanks for the reply.
How would this post request help me?

It will mark the posts as “viewed”, which is what you wrote in the first post.

How should the api request look like ?
something like this?
{{base_url}}/t/timings/topic_Id.json?

Please read Reverse engineer the Discourse API

4 个赞

You could start with following the code back to the controller. Everything you need to know about the method is there.

1 个赞

I already tried do the reverse engineering.
The only response i get from the network tab is
{{baseurl}} + /t/3295.json?track_visit=true&forceLoad=true&_=1550774445459

You gotta read it carefully.

Right clicking a request to timings and selecting copy a cURL will give you all you need for a request using the cURL syntax (the standard format for most people):

curl 'https://meta.discourse.org/topics/timings'  \
    -H 'Accept: */*' \
    -H 'Accept-Language: en-US,en;q=0.5'  \
    -H 'X-CSRF-Token: LONGTOKENHERE' \
    -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
    -H 'X-SILENCE-LOGGER: true' \
    -H 'Discourse-Logged-In: true' \
    -H 'Discourse-Visible: true' \
    -H 'X-Requested-With: XMLHttpRequest'  \
    --data 'timings%5B3%5D=1019&timings%5B4%5D=1019&topic_time=1019&topic_id=108685' \
    --compressed
6 个赞

This is what I got from the network tab


What is the the number beside the timings variable?

嗨,Edwin,你弄清楚这个 timings 变量是什么以及如何设置它了吗?我也遇到了同样的问题。

嗨 Edwin,你弄清楚如何获取数据了吗?时间安排和 topic_time?或者如何让它生效?我遇到了同样的问题。谢谢!

有人能解释一下 timings 和 topic_time 的值是什么吗?它们是花费在主题上的秒数吗?