无法使用或连接到 Mailmans REST api

无法使用或连接到 Mailmans REST api

我正在尝试使用 Mailman3 的 REST API。我已按照以下说明安装了 Mailman Bundler这里. 我正在按照找到的说明这里

我让 Postorius 和 HyperKitty 完美运行。我使用位于 localhost:8000 的 UI 创建了一个测试邮件列表。

来自 wiki.list.org/Mailman3 中关于 mailman 客户端的内容:

The official Python 2 and 3 bindings to the administrative REST API. Used by Postorius and HyperKitty, this provides a convenient, object-based API for programmatic access to the Core

由于我的 Postorius 和 HyperKitty 正在运行并能够创建列表,我知道一切都已安装并正常运行。显然,错误出在我这边。

当我尝试访问:localhost:9001/3.0/lists (如 pythonhosted 网站上所述)(链接在我的第一个段落中)时,我的浏览器中出现一条错误:

The server localhost refused to allow this computer to make a connection.

我希望在这里将 JSON 返回到屏幕。我在谷歌的“Postman”应用程序中尝试过这个,它只是一个用于测试 REST api 请求和其他 GET/POST 请求的应用程序,我得到了一个非常相似的错误,说:

This seems to be an error connecting to http://localhost:9001/3.0/lists

我是不是漏掉了什么步骤?也许是类似于启动 Web 界面/UI 的步骤,但我没有启动 UI,而是初始化了访问权限以及从端口 9001 返回数据的能力?

不管怎样。我打算使用 cURL 从 PHP 调用此 REST api。连接到 REST api 是整个设置的最后一步,所以我想把设置放在一边,继续前进。

我对 Python 不太了解。提前感谢你的帮助。

答案1

尽管该文档是这么说的,但 API 的端口是 8001,您使用基本身份验证登录。我个人使用 cURL 连接到 API。

答案2

以下是在 Debian 上测试 mailman3 REST API 的方法:

eval $(grep REST_API /etc/mailman3/mailman-web.py |sed 's/ = /=/')
curl --user $MAILMAN_REST_API_USER:$MAILMAN_REST_API_PASS http://localhost:8001/3.0/system/versions

或者:

$ /usr/share/mailman3-web/manage.py mmclient
>>> client.system

相关内容