使用Net::XMPP注册帐户



我尝试用以下代码注册新帐户:

my @result = $client->RegisterSend(
    to => 'server',
    username => 'user',
    resource => 'res',
    password => '123456'
    email => 'e@ma.il'
);

但它返回403禁止。在我的ejabberd服务器上启用了注册选项,其他客户端(如pidgin)可以创建帐户。为什么它在perl中不起作用?

您需要在配置文件中检查以下内容:

  • 确保注册已启用并向所有人开放:

    ###   ============
    ###   ACCESS RULES
    access:
    ...
      ## In-band registration allows registration of any possible username.
      ## To disable in-band registration, replace 'allow' with 'deny'.
      register: 
        all: allow
    modules: 
      mod_register: 
        welcome_message: 
          subject: "Welcome!"
          body: |-
            Hi.
            Welcome to this XMPP server.
        ip_access: trusted_network
        access: register
    
  • 请确保遵守ip_access规则。

  • 确保您没有尝试批量注册,也没有违反每个ip的注册速率调节(检查全局registration_timeout参数的值)。

参考:ejabberd文档:mod_register

最新更新