PHP/API to check whether user exists (by email) and is in specific group

I’m just starting to look at the API documentation now, and wonder whether someone could share a PHP script that uses the Discourse API to do any of the following, or anything similar.

  • use an email address to check whether a user exists - is adminListUsers the best way, or is the a more direct approach?
  • use a username/id to check whether the user is in a specific group - is listGroupMembers the best way or, as above, is there a more direct approach?
  • create a user - createUser
  • add user to group - addGroupMembers

I’ve seen the examples at "BAD CSRF" when executing PUT using API, curl, and PHP - #3 by hjalali and Sync DiscourseConnect user data with the sync_sso route so will likely start from there.

Your best bet is to Reverse engineer the Discourse API to see how those things work.

I think there may be another endpoint to get user by email address, but the one on admin/users should work.