使用 fabiang 注销 ejabbered 用户 php

unregister ejabbered user with fabiang php

我使用 fabiang php 示例 (https://github.com/fabiang/xmpp/blob/master/example.php) 成功注册了新用户。但是当我尝试删除命令时它失败并显示

<error code='405' type='cancel'><not-allowed xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/><text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>The query is only allowed from local users</text></error>

我注意到即使我没有登录我也可以注册新用户,所以我怀疑我的身份验证没有按预期的方式进行删除。如何使用fabiang进行sha1认证?

我可以使用 sha1 身份验证从 android 应用中注销,没有问题。

我明白了,要注销用户,您必须以该用户身份登录(而要注册,您必须以管理员身份登录)。

$this->implementation = new Implementation($withAuthentication);
$this->options = new \Fabiang\Xmpp\Options('tcp://...');
$this->options->setImplementation($this->implementation);
$this->options->setLogger($this->logger)
  ->setUsername($xmppuser)
  ->setPassword($xmpppass)
  ->setTimeout(self::XMPP_TIMEOUT);

$this->client = new \Fabiang\Xmpp\Client($this->options);

$listener = new UnRegistrationListener();
$unRegistrationObj = new UnRegistration();

$this->client->connect();
$this->implementation->registerListener($listener);
$this->client->send($unRegistrationObj);
$this->client->disconnect();

来自 ProtocolImplementationInterface 的注销消息如下所示:

public function toString()
{
return \Fabiang\Xmpp\Util\XML::quoteMessage(
  "<iq id='%s' type='set'><query xmlns='jabber:iq:register'><remove></remove></query></iq>",
  \Fabiang\Xmpp\Util\XML::generateId()
);
}