So, when we get a post like so:
GET /posts/13.json
We can see in the json actions_summary which contains the number of likes the post has. And you can deduce if the user I am logged in as has liked if “acted” or “can_act” is present.
"actions_summary": [
{
"id": 2,
"count": 2,
"acted": true
},
But, how do I lookup which users liked the post? We have 2 likes here, one is mine since “acted” is true. But there is one other like. How do I find out which user that is through the API? It is fine if we have to use an admin account to check.
「いいね!」 3
Falco
(Falco)
2018 年 12 月 6 日午後 1:22
2
As explained at How to reverse engineer the Discourse API
curl 'https://meta.discourse.org/post_action_users?id=507029&post_action_type_id=2'
「いいね!」 3
Your link does not work.
This works for me though:
GET /post_action_users?id=13&post_action_type_id=2
This outputs
{
"post_action_users": [
{
"id": 1,
"username": "ausername",
"name": null,
"avatar_template": "/letter_avatar_proxy/v2/letter/i/{size}.png",
"post_url": null,
"username_lower": "ausername"
},
{
"id": 10,
"username": "anotherusername",
"name": null,
"avatar_template": "/letter_avatar_proxy/v2/letter/{size}.png",
"post_url": null,
"username_lower": "anotherusername"
}
]
}
Which is a list of users who liked the post with id 13
Falco
(Falco)
2018 年 12 月 6 日午後 1:37
4
It was missing the accept header:
curl 'https://meta.discourse.org/post_action_users?id=507033&post_action_type_id=2' -H 'Accept: application/json'
「いいね!」 3
pontus.dualdecade:
post_action_users?
you need to pass
/post_action_users.json?id=507033&post_action_type_id=2
paigen11
(Paige N)
2022 年 4 月 27 日午後 7:09
6
こんにちは!
当社の利用しているDiscourseフォーラム https://discuss.blues.io/ についても同様のことを確認しようとしています。
スタッフレベルの認証情報を持っていますが、いいねされた投稿のJSONペイロードを見ても、actions_summary や post_action_users のJSONペイロードのどちらにもその兆候が見られません。
例えば、こちらの投稿 には多くの返信と「いいね」がありますが、ブラウザで https://discuss.blues.io/post_action_users.json?id=31&post_action_type_id=2 をクエリしても、{"post_action_users":[]} という応答しか返ってきません。
APIが変更されたのでしょうか?それとも、私が間違ったものをクエリしているのでしょうか。何か助けていただけると幸いです。
そして、フォローアップの質問ですが、ユーザーと投稿を特定して、ユーザーがいいねをしたときに通知を受け取れるようなWebhookを設定することは可能でしょうか?この情報を分析目的で収集したいと考えています。
よろしくお願いします!
「いいね!」 1
leonardo
(Leonardo Mosquera)
2022 年 5 月 18 日午後 4:32
10
こんにちは、Paigeさん!
ID 31 の投稿は、トピックをグローバルにピン留めするための小さな投稿アクションです(つまり、Post.find(31).action_code == 'pinned_globally.enabled')。これらの投稿は通常の投稿のように操作できないため、いいねが付くことはありません。
そのトピックには通常の投稿が1つしかありませんが、それにもいいねは付いていません。
投稿 33 を試してみてください。この投稿にはいいねが付いており、ここでシリアライズされたものを見ることができます。
https://discuss.blues.io/post_action_users.json?id=33&post_action_type_id=2
「いいね!」 5
paigen11
(Paige N)
2022 年 5 月 18 日午後 6:34
12
レオナルド様
投稿の種類に関する情報提供ありがとうございます。大変参考になりました。
ご返信に感謝いたします。
パージ
「いいね!」 2