有ejabberd python库吗? [英] Is there an ejabberd python library?

查看:52
本文介绍了有ejabberd python库吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个ejabberd python库,可以在其中以编程方式从python注册用户到ejabberd?

Is there an ejabberd python library wherein I can register user to ejabberd from python programmatically?

现在我正在使用python命令执行 ejabberdctl register命令

Right now I'm executing "ejabberdctl register" command using the python commands module.

推荐答案

XMPP XEP-0077



如果已激活 mod_register for <在您的Ejabberd服务器上进行href = http://xmpp.org/extensions/xep-0077.html rel = noreferrer>带内注册,然后,如@Drake所指出的,您可以使用XMPP库注册用户。

XMPP XEP-0077

If you have activated mod_register for In-Band registration on your Ejabberd server, then, as pointed out by @Drake, you can use an XMPP library to register users.

在Python中,我建议 Sleek XMPP 入门示例是一个很好的起点。

In Python, I would recommend Sleek XMPP. The Getting started examples are, well, a good starting point.

如果您已激活 mod_register_web ,则您可以将HTTP POST请求发送到 http://< SERVERNAME> ;:5280 / admin / server /< VIRTUALHOSTNAME> /用户/ 。该URL需要以下3个参数:

If you have activated mod_register_web then you can send a HTTP POST request to http://<SERVERNAME>:5280/admin/server/<VIRTUALHOSTNAME>/users/. This URL expects the following 3 parameters:


  • newusername

  • newuserpassword

  • addnewuser

其中 addnewuser 参数的期望值似乎

假设您有 ejabberd管理员用户名为 user ,密码为密码,使用请求HTTP库对于Python,您可以执行以下操作:

Assuming you have an ejabberd admin user called user and with password password, using the requests HTTP library for Python, you could 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

这篇关于有ejabberd python库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆