According to a reply by @Falco on my post, there’s a way to set users to watch categories using the API. I’ve spent hours searching the web and combing through the API documentation but I cannot find this call.
Does anyone know what API call could be used to set a user to watch a specific category?
You can search for "reverse engineer api " for tips on how to figure out the API call. Also, there is a plugin that will make people in a certain group follow a set of categories.
Thanks for the reply @pfaffman. Are you suggesting the API documentation is incomplete and I need to reverse engineer the API code to find the undocumented API call?
I’m sure @Osama’s method works, but setting user watches via the category seemed a bit weird to me. The following sets the watch list directly against the user (This is via python requests, but shows what is required).
DISCOURSE_URL - domain, including http(s)
username - user to change
DISCOURSE_API_KEY - api key generated by, and associated with a user
DISCOURSE_API_USERNAME - user who the key is associated with
watch_category - a list of categories the user should be watching
I’m not sure if this code can accomplish what I’m looking to do, but…
I’d like to add a hyperlink that would have some kind of URL parameter that when a user clicked the link, they would be Watching/Tracking/Normal/Muted for a particular category.
Practical use case would be instead of me telling folks to Visit the category… and click the bell icon and choose _____… I could say something like…
CLICK HERE if you want to be notified whenever a new post is added to this forum.
Then, when the users clicks that hyperlink, they are subscribed at the level we define, in the url parameter.
I think this would be relatively straightforward to write as a plugin or theme component, some kind of embeddable entity which can make these actions for you. The issue with the AJAX code posted above is that you are sending the global all users API key to the client. This is totally a bad idea.
The issue you will have with creating a link, as per the OP, is that the API call requires a REST POST action and links can only issue a REST GET action.