我在使用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
将用户添加到Roster我使用以下代码
$jid="xyz@domainname";
//Add to roster
$data=$api->addToRoster("abc", $jid);
哪个指向OpenFireRestApi.php
哪个函数名为addToRoster
/**
* Adds to this OpenFire user's 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'));
}
所以我已经
了$data=$api->addToRoster("abc", $jid,"DummyName",3);
其中3是订阅类型,因为两者都是= 3,即mentioned.
但是当我添加用户时,只显示订阅类型 none 。
更新
我开始了解subscription plugin
插件本身表示会自动订阅。
之后我再次尝试
$data=$api->addToRoster("abc", $jid);
哪些方面有效,但再次订阅仅无。
任何帮助都将不胜感激。
答案 0 :(得分: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'));
}
这里我更改了参数名称。
祝你好运。