n3xt0r/zf2otrs

将 OTRS 4 集成到 ZF2

1.0.1 2015-08-12 14:55 UTC

This package is auto-updated.

Last update: 2024-09-29 04:14:15 UTC


README

OTRS 4 集成模块的 Zend Framework 2。

通过 Composer 安装

require "n3xt0r/zf2otrs": "dev-master"

之后在您的配置中启用它。

全局/本地配置

'otrs' => array(
    'url'           => 'http://example.com/otrs/nph-genericinterface.pl/Webservice',
    'username'      => 'MyUser', // Username of any agent
    'password'      => 'MyPassword', // Password of any agent
    'webservice'    => 'GenericTicketConnectorSOAP', //Webservice name
),

不要忘记在 OTRS 中添加一个 webservice。您可以使用以下配置示例: https://github.com/OTRS/otrs/blob/rel-4_0/development/webservices/GenericTicketConnectorSOAP.yml

获取服务

$oOtrsService = $this->getServiceLocator()->get("OTRS\Service\OtrsService");

通过 ID 获取特定票务

$oTicketGetResponse = $oOtrsService->getTicketByOtrsTicketId(123, true);

第一个参数:TicketID 第二个参数:获取所有文章?默认 = false

创建新票务

首先创建一个 Ticket-Object

use OTRS\Entity\Ticket;

$CustomerUser = "root@localhost";

$oTicket = new Ticket();
$oTicket->setTitle("Testtitle");
$oTicket->setQueueID(1);
$oTicket->setStateID(1);
$oTicket->setPriorityID(1);
$oTicket->setCustomerUser($CustomerUser);

其次创建一个 Article-Object

use OTRS\Entity\Article;

$oArticle = new Article();
$oArticle->setContentType("text/plain; charset=ISO-8859-15");
$oArticle->setSubject("betreff");

$oArticle->setBody("test message");
$oArticle->setFrom("customer@test.com");

然后创建请求

$aAttachments = array(); //array of \OTRS\Entity\Attachment (optional)

/** @var $oTicketCreateResponse \OTRS\Entity\TicketCreateResponse **/
$oTicketCreateResponse = $oOtrsService->createTicket($CustomerUser, $oTicket, $oArticle, $aAttachments);

调试

if($oOtrsService->hasErrorMessages()){
   print_r($oOtrsService->getErrorMessages());
}