gidkom / php-openfire-restapi Goto Github PK
View Code? Open in Web Editor NEWRemotely manage the Openfire server using Rest Api
License: MIT License
Remotely manage the Openfire server using Rest Api
License: MIT License
What I'm trying to do is, to get RID and SID values for JID in server side. The goal is to keep authenticated Converse JS (frontend client) using it's prebind future. Tried all possible PHP XMPP libraries. Starting from JAXL ending in tiniest libraries like . None of them working.
Is there any possible workaround? How can I write simple connection class to authenticate based on given username and password and get rid, sid? Is it possible using this REST solution?
hi,
am using this "$openfireApi->createGroup($groupname, $description);" to add group how i need to add owner or admin in this..?
thankyou
It throws an error:
{
"status": false,
"data": {
"message": "Server error: PUT http://ec2-18-220-60-110.us-east-2.compute.amazonaws.com:9090/plugins/restapi/v1/users/benny
resulted in a 500 Server Error
response"
}
Hi Gidkom,
Thanks for the library, its very useful and I have mentioned it in a codeproject article here
However I had a little trouble when dealing with special Jid node. This is more like a question, trying to understand the library, than a real issue, since I have found a workaround.
E.g. I would like to create test@[email protected] in an Openfire server. Openfire supports XEP 106 so this is allowed and supported. The REST API can create this user, if XEP106 is applied and the jid is defined as test\[email protected].
However, when passing to php-openfire-restapi test\[email protected] an error is raised from the REST API. I think this is due to some kind of behind the scenes escape characters added by curl. However test\[email protected] creates the test@[email protected] alright in Openfire.
So please confirm that in order to pass correctly XEP106 encoded jids, such as the one mentioned above, I should use the addslashes php function, before setting the jid to php-openfire-restapi.
I have installed the php-openfire-restapi successfully. I have also enabled the REST API on the server. I am able to get user using the $api->getUser($userName) command. But I am not able to add new user to the Openfire server with the command.
The command i used:
`<?php
include './vendor/autoload.php';
// Create the Openfire Rest api object
$api = new Gidkom\OpenFireRestApi\OpenFireRestApi;
// Set the required config parameters
$api->secret = "*********";
$api->host = "localhost";
$api->port = "9090"; # default 9090
// Optional parameters (showing default values)
$api->useSSL = false;
$api->plugin = "/plugins/restapi/v1"; // plugin
// Retrieve users
$result = $api->addUser('mamut', '123456', 'Mamut', '[email protected]');
//$Username = 'ahmat'; // optional
//$result = $api->getUser($userName);
// Check result if command is succesful
if($result['status']) {
// Display result
print_r($result['message']);
} else {
// Something went wrong
echo 'Error: ';
echo $result['message'];
}
?>
`
I got the following error when i execute above code:
PHP Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error:
POST http://localhost:9090/plugins/restapi/v1/users` resulted in a 400 Bad Request
response:
Unrecognized field "groups" (class org.jivesoftware.openfire.plugin.rest.entity.UserEntity), not marked as ignorable (5 (truncated...)
in /home/knook/scripts/RESTAPI/php-openfire-restapi/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Stack trace:
#0 /home/knook/scripts/RESTAPI/php-openfire-restapi/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create()
#1 /home/knook/scripts/RESTAPI/php-openfire-restapi/vendor/guzzlehttp/promises/src/Promise.php(204): GuzzleHttp\Middleware::GuzzleHttp{closure}()
#2 /home/knook/scripts/RESTAPI/php-openfire-restapi/vendor/guzzlehttp/promises/src/Promise.php(153): GuzzleHttp\Promise\Promise::callHandler()
#3 /home/knook/scripts/RESTAPI/php-openfire-restapi/vendor/guzzlehttp/promises/src/TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}()
#4 /home/knook/scripts/RESTAPI/php-openfire-restapi/vendor/guzzlehttp/promises/src/Promise.php(248): GuzzleHttp\Promise\TaskQueue->run()
#5 /home/knook/scripts/RESTAPI/php-openfire-restapi/vendor/guzzlehttp/promises/src/Promise.php(224): GuzzleHttp\Promise\Promise->invokeWaitFn()
#6 /home/knook/scripts/RESTAPI/php-openfire-restapi/vendor/guzzlehttp/promises/src/Promise.php(269): GuzzleHttp\Promise\Promise->waitIfPending()
#7 /home/knook/scripts/RESTAPI/php-openfire-restapi/vendor/guzzlehttp/promises/src/Promise.php(226): GuzzleHttp\Promise\Promise->invokeWaitList()
#8 /home/knook/scripts/RESTAPI/php-openfire-restapi/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#9 /home/knook/scripts/RESTAPI/php-openfire-restapi/vendor/guzzlehttp/guzzle/src/Client.php(182): GuzzleHttp\Promise\Promise->wait()
#10 /home/knook/scripts/RESTAPI/php-openfire-restapi/vendor/guzzlehttp/guzzle/src/Client.php(95): GuzzleHttp\Client->request()
#11 /home/knook/scripts/RESTAPI/php-openfire-restapi/vendor/gidkom/php-openfire-restapi/src/Gidkom/OpenFireRestApi/OpenFireRestApi.php(58): GuzzleHttp\Client->__call()
#12 /home/knook/scripts/RESTAPI/php-openfire-restapi/vendor/gidkom/php-openfire-restapi/src/Gidkom/OpenFireRestApi/OpenFireRestApi.php(118): Gidkom\OpenFireRestApi\OpenFireRestApi->doRequest()
#13 /home/knook/scripts/RESTAPI/php-openfire-restapi/test.php(18): Gidkom\OpenFireRestApi\OpenFireRestApi->addUser()
#14 {main}
thrown in /home/knook/scripts/RESTAPI/php-openfire-restapi/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113
`
I skipped the last parameter from $api->addUser function: array('Group 1'); Because i wanted to only add a user without adding to any group. I have also added a group to Openfire server name "Group 1", and i called the following function:
$result = $api->addUser('mamut', '123456', 'Mamut', '[email protected]', array('Group 1'));
But i sill got above error message.
Did i made any mistake in my code or there is something wrong with the php-openfire-restapi?
public function getRoster($username)
{
$endpoint = '/users/'.$username.'/roster';
$return $this->doRequest('get', $endpoint);
}
added this function to OpenFireRestApi.php to return a users roster, if I feed it a username though it returns a success message but apart from that the arrays are empty, just wondering if I'm missing something obvious...
I am getting this error, when running my code on shared server
with no result displaying at all
whereas everything working fine over my laptop local xamp and producing correct results.
Please help me ,what could be the issue?
Thanks
What I have tried so far?
$username = 'user1';
$jid = 'user2';
$openfire->addToRoster($username, $jid);
But I got the following error
array (size=2)
'status' => boolean false
'data' =>
array (size=1)
'message' => string 'Server error:POST http://message-server3.saedhamdan.com:9090/plugins/restapi/v1/users/user1/roster
resulted in a500 Server Error
response' (length=143)
Hi!
Your library is on version 1.1.0, but from packagist we can download version 1.0.0 only.
Thank you!
Due to the requirement of using version 5 of Guzzle some other useful packages can't be used together:
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Conclusion: remove guzzlehttp/guzzle 6.2.0
- Conclusion: remove mentos1386/opencrest 3.0.0
- Conclusion: don't install guzzlehttp/guzzle 6.2.0
- Conclusion: don't install guzzlehttp/guzzle 5.3.0
- Conclusion: don't install guzzlehttp/guzzle 6.1.1
- Conclusion: don't install guzzlehttp/guzzle 5.2.0
- Conclusion: don't install guzzlehttp/guzzle 6.1.0
- Conclusion: don't install guzzlehttp/guzzle 5.1.0
- Conclusion: don't install guzzlehttp/guzzle 6.0.2
- Conclusion: don't install guzzlehttp/guzzle 5.0.3
- Installation request for mentos1386/opencrest ^3.0 -> satisfiable by mentos1386/opencrest[3.0.0].
- Installation request for gidkom/php-openfire-restapi dev-master -> satisfiable by gidkom/php-openfire-restapi[dev-master].
- gidkom/php-openfire-restapi dev-master requires guzzlehttp/guzzle ~5.0 -> satisfiable by guzzlehttp/guzzle[5.0.0, 5.0.1, 5.0.2, 5.0.3, 5.1.0, 5.2.0, 5.3.0].
- Can only install one of: guzzlehttp/guzzle[6.0.0, 5.0.0].
- Can only install one of: guzzlehttp/guzzle[6.0.0, 5.0.1].
- Can only install one of: guzzlehttp/guzzle[6.0.0, 5.0.2].
- mentos1386/opencrest 3.0.0 requires guzzlehttp/guzzle ^6 -> satisfiable by guzzlehttp/guzzle[6.2.0, 6.0.0, 6.0.1, 6.0.2, 6.1.0, 6.1.1].
- Conclusion: don't install guzzlehttp/guzzle 6.0.1
Can it be update the 'requirements'?
cURL error 7: Failed to connect to 'x.xx.xxx.xx' port 9090: Connection refused (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://x.xx.xxx.xx:9090/plugins/restapi/v1/users
Hello folks, I am using gnello/php-openfire-restapi to manage an Openfire instance by sending a REST/HTTP request to the server. It is properly working on localhost means it is creating users on Openfire but not working on the server host.
Hello having a bit of issue figuring out why this doesnt work.
I try add user with username as email
$api->addUser('[email protected]', $password, $name, $email);
and get response 500 Server Error
Hello,
I am using $api->createGroup($group_name, $description); But it is giving me error on guzzlehttp request.
I am using guzzlehttp 5.0 in my laravel project
Hi,
Can you help us resolving the autoload.php dependency error.
We have tried to install with composer, but still couldn't resolve the dependency on autoload.php.
It would be great even if you can share the autoload.php and dependent files on git.
regards,
my code is test.php
<?php
include "vendor/autoload.php";
$api = new Gidkom\OpenFireRestApi\OpenFireRestApi;
$api->secret = "26dDyrlbCLI55YjF";
$api->host = "148.72.251.175";
$api->port = "http://opf.pissaya.info:9090"; // default 9090
$api->useSSL = false;
$api->plugin = "/plugins/restapi/rest-api.jsp"; // plugin
$result = $api->addUser('root', 'root', 'Root', '[email protected]');
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'];
}
?>
Someone can help me? I will cry happy tears!
:(
Hello having a bit of issue figuring out why this doesnt work
$result = $api->addUser('Username1', 'Passwordss', 'Real Name', '[email protected]', array('member'));
It will make the account but it doesnt add it to the group.
Type => post
body => {"username":"Username11","password":"Passwordss","name":"Real Name","email":"[email protected]","groups":["member"]}
Status Code => 201
Is it something with the code or with the jabber server.
I am facing this issue please help me
Fatal error: Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: POST http://167.114.98.145:9090/plugins/restapi/v1/users
resulted in a 403 Forbidden
response: ' in C:\xampp\htdocs\openfire\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php:111 Stack trace: #0 C:\xampp\htdocs\openfire\vendor\guzzlehttp\guzzle\src\Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 C:\xampp\htdocs\openfire\vendor\guzzlehttp\promises\src\Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response)) #2 C:\xampp\htdocs\openfire\vendor\guzzlehttp\promises\src\Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #3 C:\xampp\htdocs\openfire\vendor\guzzlehttp\promises\src\TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}() #4 C:\xampp\htdocs\openfire\vendor\guzzlehttp\promises\src\Promise.php(246): GuzzleHttp\ in C:\xampp\htdocs\openfire\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php on line 111
Can you please change to "guzzlehttp/guzzle": "^5.3.1|^6.2.1",
. It works fine and resolves compatibility issue in composer with other libraries, which use recent version of guzzle.
When trying to access a nonexisting group with:
$apiClient->getGroup('nonexistent_foobar_group');
I get a GuzzleHttp\Exception\ClientException
:
PHP Fatal error: Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error response [url] https://openfire.example.com:9091/plugins/restapi/v1/groups/nonexistent_foobar_group [status code] 404 [reason phrase] Not Found' in .../myproject/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:89
Stack trace:
0 .../myproject/vendor/guzzlehttp/guzzle/src/Subscriber/HttpError.php(33): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Message\Request), Object(GuzzleHttp\Message\Response))
1 .../myproject/vendor/guzzlehttp/guzzle/src/Event/Emitter.php(109): GuzzleHttp\Subscriber\HttpError->onComplete(Object(GuzzleHttp\Event\CompleteEvent), 'complete')
2 /home/claude-duv in .../myproject/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 89
I feel like 404 responses and (GuzzleHttp\Exception
in general) should be dealt by OpenFireRestApi
itself.
Could you please update your userservice client which is based on userservice v1 API to userservice v2?
The user service v2 is also build in REST API from openfire.
See here: http://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html
I see that this repository has a v1.1.0 but it's not visible in https://packagist.org/packages/gidkom/php-openfire-restapi
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.