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.

3 إعجابات

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

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 إعجابات

you need to pass

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

مرحباً!

أحاول التحقق من شيء مشابه لمنتدى Discourse تستخدمه شركتي: https://discuss.blues.io

لديّ صلاحيات على مستوى الموظفين، ومع ذلك، عندما أنظر إلى حمولة JSON للمشاركات التي تم الإعجاب بها، لا أرى أي إشارة إليها سواء في حمولة JSON actions_summary أو post_action_users.

على سبيل المثال، هذه المشاركة لديها العديد من الردود والإعجابات، ولكن عندما أستعلم عنها في المتصفح https://discuss.blues.io/post_action_users.json?id=31&post_action_type_id=2، أحصل على {"post_action_users":[]}

ربما تغيرت واجهة برمجة التطبيقات؟ أو أنني أستعلم عن الشيء الخطأ. أي مساعدة ستكون محل تقدير كبير.

وسؤال متابعة: هل هناك خطاف ويب (webhook) يمكنني إعداده لإعلامي عندما يقوم مستخدم بالإعجاب بمشاركة مع تحديد المستخدم والمشاركة؟ نود التقاط هذه المعلومات لأغراض التحليلات.

شكراً!

إعجاب واحد (1)

مرحباً Paige!

المنشور بالمعرف 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

5 إعجابات

مرحباً ليوناردو،

شكراً جزيلاً على المعلومات حول أنواع المنشورات المختلفة - هذه معلومات رائعة لمعرفتها.

أقدر ردك.

مع خالص تحياتي،
بيج

إعجابَين (2)