Closed C-Duv closed 8 years ago
thanks a lot. I will work on that
How to create group on openfire and then add member on group using url
I want to create group on open fire and then add member on that group using url. i have create the user on open fire by using this url http://myhostname:port/plugins/userService/userservice?type=add&secret=mysecretkey&username=$username&password=$password&name=$name&email=$email
Please help me to create group and add users on that group and i have used this url to create group http://myhostname:port/plugins/userService/userservice?type=add&secret=mysecretkey&name='spalchat'&description='parent'
but it throws an exception:
First of all user service plugin is deprecated. You should use the Rest API plugin. Go through the docs on its usage (http://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html)
yes i have read this docs,but my question is there any url to create group on openfire because i have created the user on openfire by URL so i have to use user service plugin is it possible?
Hi Gidkom,
I have http://www.igniterealtime.org/projects/openfire/plugins/restapi installed on openfire. But still I am getting the below error:
[07-Dec-2015 15:41:36 America/Detroit] PHP Fatal error: Uncaught exception 'GuzzleHttp\Ring\Exception\ConnectException' with message 'cURL error 7: See http://curl.haxx.se/libcurl/c/libcurl-errors.html' in /home/websoftt/public_html/portfolio/sites/jugaado/chat/vendor/guzzlehttp/ringphp/src/Client/CurlFactory.php:126 Stack trace:
Below is my code:
<?php
include "vendor/autoload.php";
// Create the Openfire Rest api object $api = new Gidkom\OpenFireRestApi\OpenFireRestApi;
// Set the required config parameters $api->secret = "SECRET"; $api->host = "MY HOST"; $api->port = "9090"; // default 9090
// Optional parameters (showing default values)
$api->useSSL = false; $api->plugin = "/plugins/restapi/v1"; // plugin
// Add a new user to OpenFire and add to a group $result = $api->addUser('dibsisbest@openfire', 'password', 'Real Name', 'dibsisbest@jugaado.com', array());
// Check result if command is succesful if($result['status']) { // Display result, and check if it's an error or correct response echo 'Success: '; echo $result['message']; } else { // Something went wrong, probably connection issues echo 'Error: '; echo $result['message']; }
?>
@dibwas please see this issue The error could be caused by the @ character in the jid node, it must be escaped as \40
Hi Gidkom,
The issue did not resolve after using \40 in place of @ in email field.Can you please let me know how to come out from this given below exception.
PHP Fatal error: Uncaught exception 'GuzzleHttp\Exception\ServerException' with message 'Server error response [url] http://openfire.smartchk.net:9090/plugins/restapi/v1/users [status code] 500 [reason phrase] Server Error' in /var/www/html/XMPP_POC/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:89
can use php exception handling to work round this one... I wrote a script to add all users as buddies to all other users, and use a try - catch block as a quick and dirty way to ignore conflicts caused when a user is already in someones roster...
the exception message should also give you a better clue whats happened..
$result = $api->getUsers();
if($result['status']){
foreach ($result['message']->user as $value) {
if($value->username != $q){
try {
$setresult = $api->addToRoster($q, $value->username.'@'.$jidfinish);
echo $value->username." added to : ".$q."
";
} catch (Exception $e) {
echo "Caught Exception : ".$e->getMessage(), "<br >";
}
}
}
unset($value);
} else {
echo 'Error';
print_r ($result['message']);
}
When trying to access a nonexisting group with:
I get a
GuzzleHttp\Exception\ClientException
:I feel like 404 responses and (
GuzzleHttp\Exception
in general) should be dealt byOpenFireRestApi
itself.