Does anybody fancy trying to wrap their head round the Discourse API?
In theory, anything you can do with the regular site can be done via your own code; all you have to do is keep an eye on the Network tab of browser devtools and see what calls are made as you do things.
So they say. It’s all Greek to me!
What I’d really like to see is an enhancement for our membership system that automatically creates/invites a Discourse account when creating a new member, and automatically promotes that account to the “Members” user group when their payment goes through (and demotes them when they cancel). We have to do this manually right now, which is a pain.
Hello, I’m not sure to be honest it depends on discourse API I guess. I’m not that experienced on developing these kinds of applications more on the visual and interactive side of things. I’ll have a little search around though to get a better idea.
I’ll have a look into this too. Might be a fun challenge. What is the main functionality we would need on the app? Purely the membership control and notifications?
I’m taking baby steps in customising our Discourse installation by attempting to write a plugin that will allow custom content in the main header, eg this big expanse of empty space:
So first of all, the group id for Members is 41 (you could verify this out with https://discourse.southlondonmakerspace.org/admin/groups.json lookup if you like.
Note the plural “usernames=” for the adding process (will accept a comma seperated list of usernames to promote) and the singular “username=” for the group removal (one user at a time)
Auto-creating a discourse account during signup (if none exists) would be nice too. For that you use
curl -X POST --data "name=FullName&username=UserName&email=Name@Domain.TLD&password=Password&active=true" https://discourse.southlondonmakerspace.org/users?api_key=ApiKeyGoesHere&api_username=Makerspace
The latest advice from the Discourse devs is that I should
be putting the api_key in the form data if possible.
Like this?
curl -X PUT -F api_key=blahblahbalh -F api_user=username -d usernames=username https://etc.etc.
But I haven’t tested that yet
It should be a simple matter for someone to string this all together into a script. Further intelligence will be required for edge cases, eg. SLMS member email not matching Discourse email. If anyone fancies having a play, let me know and I’ll give you the API key