Openfire: Add a user with a subscription status of both

I encounter a problem when I add a user using RestApi

include "vendor/autoload.php";
$api = new Gidkom\OpenFireRestApi\OpenFireRestApi;
$api->secret = "mySecretKey";
$api->host = "HostName";
$api->port = "9090";
$api->useSSL = false;
$api->plugin = "/plugins/restapi/v1";  // plugin 

To add a user to the list, I use the following code

$jid="xyz@domainname";
//Add to roster
$data=$api->addToRoster("abc", $jid);

Which points to OpenFireRestApi.phpwhich have a function namedaddToRoster

 /**
     * Adds to this OpenFire user roster
     *
     * @param   string          $username       Username
     * @param   string          $jid            JID
     * @param   string|false    $name           Name         (Optional)
     * @param   int|false       $subscription   Subscription (Optional)
     * @return  json|false                     Json with data or error, or False when something went fully wrong
     */
    public function addToRoster($username, $jid, $name=false, $subscription=false)
    {
        $endpoint = '/users/'.$username.'/roster';
        return $this->doRequest('post', $endpoint, compact('jid','name','subscription'));
    }

So I used

$data=$api->addToRoster("abc", $jid,"DummyName",3);

Where 3 is the type of subscription, as indicated as = 3, which is indicated

But when I add, the user shows the type of subscription as none .

UPDATE

I found out about the subscription plugin

So, I installed the plugin to configure it enter image description here

The plugin itself says that it will be automatically signed in both directions.

Subsequently, I tried again

$data=$api->addToRoster("abc", $jid);

What are the aspects of work, but again the subscription, none .

Any help would be appreciated.

+4
1

php-openfire-restapi

:

//Add to roster
$username = "username in which you want to add roster";
$jid = "another users JID";
$nickname= "nick name of another user";
$subscription ="3";
$result = $api->addToRoster($username, $jid,$nickname,$subscription);

/src/Gidkom/OpenFireRestApi/OpenFireRestApi.php

public function addToRoster($username, $jid, $name=false, $subscription=false)
    {
        $nickname=$name;
        $subscriptionType=$subscription;
        $endpoint = '/users/'.$username.'/roster';
        return $this->doRequest('post', $endpoint, compact('jid','nickname','subscriptionType'));
    }

.

.

+1

All Articles