Determinare se l'utente API autenticato ha messo mi piace al post nella risposta dell'API getTopic

Ho lavorato per l’ultima settimana a un plugin di commenti per WordPress e ho ottenuto grandi risultati nel connettermi, creare post e aggiornare dati tramite l’API di Discourse e la mia versione modificata del plugin discourse-php-API: Work through the createPost request to get it working by benbowler · Pull Request #14 · communiteq/discourse-api-php · GitHub

Esaminando la risposta di /posts, vedo il riepilogo delle azioni per ogni post e ottengo il conteggio totale dei “mi piace”.

actions_summary: Array(6)
0: {id: 2, count: 1, can_act: true}
1: {id: 3, can_act: true}
2: {id: 4, can_act: true}
3: {id: 8, can_act: true}
4: {id: 6, can_act: true}
5: {id: 7, can_act: true}
length: 6
__proto__: Array(0)

Tuttavia, can_act è true indipendentemente dal fatto che l’utente abbia già messo “mi piace” al post. Come si mostra correttamente questo stato?

If the user you’re using with the API (Api-Username) has liked a post, you should see acted: true

Hmm, let me take a look.

I’ve got it. The plugin wasn’t requesting based on the passed user. I’ll update the library to help anyone in future.

2 Mi Piace