XMPP XEP-0077
If you activated mod_register to Register in a group on your Ejabberd server, then, as @Drake points out, you can use the XMPP library to register users.
In Python, I would recommend Sleek XMPP . Startup examples are a good starting point.
HTTP
If you activated mod_register_web , you can send an HTTP POST request to http://<SERVERNAME>:5280/admin/server/<VIRTUALHOSTNAME>/users/ . This URL expects the following 3 parameters:
- newusername
- newuserpassword
- addnewuser
where the expected value for the addnewuser parameter seems to be the βAdd Userβ line.
Assuming you have an ejabberd admin user called user and with password password , using the request HTTP library for Python, you can do something like the following:
import requests from requests.auth import HTTPBasicAuth server = "NAME OF YOUR EJABBERD SERVER" virtualhost = "NAME OF YOUR EJABBERD HOST" url = "http://%s:5280/admin/server/%s/user/" % (server, virtualhost) auth = HTTPBasicAuth("user", "password") data = { 'newusername': "new_user", 'newuserpassword': "new_password", 'addnewuser': "Add User" } resp = requests.post(url, data=data, auth=auth) assert resp.status_code == 200
Rodrigue
source share