Get number of likes for a single post?

Hello,
I’m trying to get the number of likes for a single post via the API, but can’t seem to find it…

I see a like_count for the entire topic, but can’t seem to find the individual like count for each post in either /t/123.json or /posts/222.json.

I noticed that I can get a list of users who liked a post via /post_action_users.json and add them up manually, but what is the recommended way to to get the “like count” for an individual post?

Thanks!

2 „Gefällt mir“

I’m an idiot!
Found it under "actions_summary":

{"id":2,"count":5,"acted":true}

Well, hope this helps someone else!

16 „Gefällt mir“

Love you man! that helps me a lot!

Leider entfernt Discourse diese Eigenschaft, wenn der Beitrag keine Likes hat.
Außerdem ist sie nicht in der API-Dokumentation aufgeführt: Discourse API Docs, Discourse API Docs

Daher unzuverlässig und der Code wird durch unnötige „if property object exist“-Prüfungen verschmutzt.
Sollte im besten Fall verbessert werden.

1 „Gefällt mir“

Vielen Dank für Ihr Feedback. Ja, wenn ich mir die API-Dokumentation ansehe, gibt es keine Informationen zum Abrufen von Likes, nur zum Erstellen. Ich werde zunächst die API-Dokumentation in diesem Bereich verbessern.

1 „Gefällt mir“

Das liebe ich definitiv an dir.
Wenn ich dabei helfen kann (ist das von Menschen geschrieben?!) lass es mich wissen.
Aber ich vermute, du verwendest so etwas wie PHPdoc, nur für Ruby oder was auch immer Discourse in geschrieben ist?
Ich habe keine Erfahrung in dieser Sprache, also wenn es programmatisch ist, kann ich (noch) nicht damit helfen :stuck_out_tongue:

1 „Gefällt mir“

Ich würde sagen, es ist 50/50. Es gibt immer noch manuelle Arbeit, aber sie werden aus rspec-Tests mit einem Tool namens rswag generiert.

1 „Gefällt mir“

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.