I´m working with the Discourse API.
The website I’m working on gets all the data from the Discourse API. I’m having the issue that because I’m actually not viewing the Topics and Notification, and only getting data through the api, then my topics and notification are not registered as viewed.
How should I solve this issue?
joebuhlig
(Joe Buhlig)
2019 年 2 月 21 日午後 3:36
2
If I’m following, you need to make an API call to this endpoint:
put "t/:id" => "topics#update"
delete "t/:id" => "topics#destroy"
put "t/:id/archive-message" => "topics#archive_message"
put "t/:id/move-to-inbox" => "topics#move_to_inbox"
put "t/:id/convert-topic/:type" => "topics#convert_topic"
put "t/:id/publish" => "topics#publish"
put "t/:id/shared-draft" => "topics#update_shared_draft"
put "t/:id/reset-bump-date" => "topics#reset_bump_date"
put "topics/bulk"
put "topics/reset-new" => 'topics#reset_new'
post "topics/timings"
get 'topics/similar_to' => 'similar_topics#index'
resources :similar_topics
get "topics/feature_stats"
scope "/topics", username: RouteFormat.username do
get "created-by/:username" => "list#topics_by", as: "topics_by", constraints: { format: /(json|html)/ }, defaults: { format: :json }
get "private-messages/:username" => "list#private_messages", as: "topics_private_messages", constraints: { format: /(json|html)/ }, defaults: { format: :json }
get "private-messages-sent/:username" => "list#private_messages_sent", as: "topics_private_messages_sent", constraints: { format: /(json|html)/ }, defaults: { format: :json }
「いいね!」 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.
joebuhlig:
topics/timings
How should the api request look like ?
something like this?
{{base_url}}/t/timings/topic_Id.json?
Falco
(Falco)
2019 年 2 月 21 日午後 6:37
6
「いいね!」 4
joebuhlig
(Joe Buhlig)
2019 年 2 月 21 日午後 6:42
7
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
Falco
(Falco)
2019 年 2 月 21 日午後 7:01
9
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?
ryze1
2020 年 11 月 30 日午後 1:28
11
Hi Edwin, did you figure out what this timings variable was an dhow to set it? have same problem.
Edwinさん、データ(timingsやtopic_time)を取得する方法、またはそれを機能させる方法を見つけましたか?私も同じ問題を抱えています。よろしくお願いします!
manojm321
(Manoj Kumar Manikchand)
2023 年 3 月 4 日午後 5:52
13
timings と topic_time の値について誰か説明してもらえますか?トピックに費やされた秒数ですか?