【发布时间】:2016-04-12 19:18:46
【问题描述】:
目前我在我的服务器上安装了 openfire 并开始使用它。我尝试使用 Restapi 在 openfire 中创建用户。我得到了预期的输出。
现在我尝试使用已经存在的用户名“abcdef”创建用户。我想要一条显示“用户名已存在”的消息,但我得到了一个异常。
例外:
Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error response [url] http://myip:9090/plugins/restapi/v1/users [status code] 409 [reason phrase] Conflict' in /var/www/html/open_fire_internal/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:88
来自异常的消息:
客户端错误响应 [url] http://myip:9090/plugins/restapi/v1/users [状态码] 409 [原因短语] 冲突
堆栈跟踪:
#0 [...]/vendor/guzzlehttp/guzzle/src/Subscriber/HttpError.php(33): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Message\Request), Object(GuzzleHttp\Message\Response))
#1 [...]/vendor/guzzlehttp/guzzle/src/Event/Emitter.php(109): GuzzleHttp\Subscriber\HttpError->onComplete(Object(GuzzleHttp\Event\CompleteEvent), 'complete')
#2 [...]/vendor/guzzlehttp/guzzle/src/RequestFsm.php(91): GuzzleHttp\Event\Emitter->emit('complete', Object(GuzzleHttp\Event\CompleteEvent))
#3 [...]/vendor/guzzlehttp/guzzle/src/RequestFsm.php(132): GuzzleHttp\RequestFsm->__invoke(Object(GuzzleHttp\Transaction))in /var/www/html/open_fire_internal/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 88
那么任何人都可以帮助我克服这个问题吗?
【问题讨论】:
-
你能出示你的代码吗!
-
include "../vendor/autoload.php";987654325$api = new Gidkom\OpenFireRestApi\OpenFireRestApi;987654327$result = $api->addUser('kandan', 'mani');987654329if($result['status']) {987654331echo 'Success: ';987654333} else {987654335echo 'Error: ';987654337 @} -
当用户名在 openfire 中不存在时,我会收到成功消息,但当用户名在 openfire 中存在时,我会收到该异常。