Getting who liked a post from the API

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.

As explained at Reverse engineer the Discourse API

curl 'https://meta.discourse.org/post_action_users?id=507029&post_action_type_id=2'

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

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'

전달해야 합니다

/post_action_users.json?id=507033&post_action_type_id=2

안녕하세요!

저희 회사가 사용하는 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가 변경된 것일까요? 아니면 제가 잘못된 것을 조회하고 있는 걸까요. 도움이 크게 절실합니다.

그리고 추가 질문이 하나 있습니다. 사용자가 게시물을 좋아하면 해당 사용자와 게시물을 식별할 수 있도록 알려주는 웹훅을 설정할 수 있을까요? 이 정보를 분석 목적으로 수집하고 싶습니다.

감사합니다!

페이징, 안녕하세요!

ID가 31인 게시글은 주제를 전역으로 고정하기 위한 작은 게시글 액션입니다(예: Post.find(31).action_code == 'pinned_globally.enabled'). 이러한 게시글은 일반 게시글처럼 상호작용할 수 없기 때문에 좋아요를 받을 수 없습니다.

해당 주제에는 일반 게시글이 단 하나만 있으며, 이 게시글에도 좋아요가 없습니다.

게시글 33을 시도해 보세요. 이 게시글에는 좋아요가 있으며, 여기서 직렬화된 내용을 볼 수 있습니다:

https://discuss.blues.io/post_action_users.json?id=33&post_action_type_id=2

레오나도, 안녕하세요.

게시물의 다양한 유형에 대한 정보를 알려주셔서 정말 감사합니다. 알아두면 아주 유용한 정보네요.

답변 주셔서 감사드립니다.

감사합니다.
페이이지