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

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

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

Well, hope this helps someone else!

「いいね!」 16

Love you man! that helps me a lot!

残念ながら、Discourse は投稿に「いいね!」がない場合、そのプロパティを削除します。
また、API ドキュメントにも記載されていません: Discourse API Docs, Discourse API Docs

そのため、信頼性が低く、コードが不要な「if property object exist」によって汚染されます。
改善されるべきです。

「いいね!」 1

フィードバックありがとうございます。APIドキュメントを見ると、いいねの作成方法については記載がありますが、取得方法については情報がありません。まずはその部分のAPIドキュメントを改善することから始めます。

「いいね!」 1

それについては本当に感謝しています。
これが(人間が書いたものですか?!)お手伝いできることがあればお知らせください。
しかし、Discourseが書かれているRuby、あるいはそれに類するものにPHPdocのようなものを使用しているのではないかと推測しています。
その言語の経験がないため、プログラム的なものであれば(まだ)お手伝いできません :stuck_out_tongue:

「いいね!」 1

50/50だと思います。手作業もまだありますが、rspecテストからrswagというツールを使って生成されています。

「いいね!」 1

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