0
我試圖從Openfire的文件夾Github的Openfire RESTAPI爲PHP配置
現在我已經安裝了插件RESTAPI連接到使用RESTAPI我的Openfire服務器。 我在CentOS 7
<?php
include "vendor/autoload.php";
$api = new \Gnello\OpenFireRestAPI\API();
//Set the required config parameters
$api->Settings()->setSecret("YWRtaW46YWRtaW4");
$api->Settings()->setHost("localhost");
$api->Settings()->setServerName("localhost");
//Default values
$api->Settings()->setPort("9090");
$api->Settings()->setSSL(false);
$api->Settings()->setPlugin("/plugins/restapi/v1");
現在WhenI嘗試連接它顯示錯誤:
if($result['response']) {
echo $result['output'];
} else {
echo 'Error!';
}
在httpd的日誌,它說未定義$結果是顯而易見的。
但我按照它的存儲庫中提到的步驟操作。
任何一個請指導我如何使用它?
#Udated
include "vendor/autoload.php";
$api = new \Gnello\OpenFireRestAPI\API();
//Enable debug mode
$api->Settings()->setDebug(true);
$requests = \Gnello\OpenFireRestAPI\Debug\Request::getRequests();
//var_dump($api);
//var_dump($requests);
$result = $api->users();
//var_dump($api);
$username ="test2";
$results = $api->getuser($username);
if($result['response'])
{
echo $result['output'];
}
else
{
echo 'Error!';
}
在開發中,您可能需要訪問一些有用的信息,這些信息通常不可用。爲此,只需啓用調試模式,如下所示: //啓用調試模式 $ api-> Settings() - > setDebug(true); – JYoThI
我試圖啓用調試模式,但沒有好處:(它不顯示任何東西在屏幕上@JYoThI – Rajan
你必須執行任何事情,然後得到像這樣的$結果//添加一個新用戶 $ properties = array('key1'= >'value1','key2'=>'value2'); $ result = $ api-> Users() - > createUser('用戶名','密碼','全名','[email protected]' ,$ properties); if($ result ['response']){ echo $ result ['output']; } else { echo'Error!'; } – JYoThI