Git Product home page Git Product logo

php-openfire-restapi's People

Contributors

alfredog1976 avatar emamirazavi avatar gidkom avatar gitter-badger avatar ottoszika avatar tibo9 avatar umpirsky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-openfire-restapi's Issues

Is there pre-bind future for getting SID, RID for frontend XMPP Clients?

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?

Handling of XEP 106 special characters

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.

Add New User Failed

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?

am I being dumb?

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...

Client::request()

12312

PHP Fatal error: Call to undefined method GuzzleHttp\Client::request() in /var/www/html/www/test/vendor/gidkom/php-openfire-restapi/src/Gidkom/OpenFireRestApi/RestClient.php on line 56

Why is that? What am I doing wrong?

$api->addToRoster() is not working

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 a 500 Server Error response' (length=143)

Fix packagist

Hi!

Your library is on version 1.1.0, but from packagist we can download version 1.0.0 only.

Thank you!

Update Guzzle to >5.0

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

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.

Issue with Gidkom Group Creation

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

Stuck a error when using plugin

I m getting a error like this
screenshot from 2017-05-31 17 12 56

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!
:(

Doesnt add user to group

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.

Uncaught exception 'GuzzleHttp\Exception\ClientException'

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

Remove Guzzlehttp version restriction

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.

Handle GuzzleHttp\Exception inside client

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.