onbalt/servicedeskplus-api
Composer 安装命令:
composer require onbalt/servicedeskplus-api
包简介
Laravel integration with ManageEngine ServiceDesk Plus API
README 文档
README
Installation
This is a Laravel package so you can install it via Composer. Run this command in your terminal from your project directory:
composer require onbalt/servicedeskplus-api
Laravel Configuration
Below Laravel 5.5 you have to call this package service in config/app.php config file. To do that, add this line in app.php in providers array:
Onbalt\ServicedeskplusApi\ServicedeskplusApiServiceProvider::class,
Below Laravel 5.5 version to use facade you have to add this line in app.php to the aliases array:
'ServicedeskplusApi' => Onbalt\ServicedeskplusApi\Facades\ServicedeskplusApi::class,
Now run this command in your terminal to publish this package config:
php artisan vendor:publish --tag=servicedeskplus-api-config
after publishing your config file, open config/servicedeskplus-api.php and fill your SDP URL and technician key:
return [ 'api_base_url' => env('SDPAPI_BASE_URL', 'http://helpdesk.local/api/v3/'), 'technician_key' => env('SDPAPI_TECHNICIAN_KEY', 'key'), 'api_version' => env('SDPAPI_VERSION', '3'), 'api_v1_format' => env('SDPAPI_V1_FORMAT', 'json'), 'timeout' => 60, ];
also you can add config parametrs in .env file:
SDPAPI_BASE_URL=http://helpdesk.local/api/v3/
SDPAPI_TECHNICIAN_KEY=YOUR_TECHNICIAN_KEY
Laravel Usage
use Onbalt\ServicedeskplusApi\Facades\ServicedeskplusApi; // View Request $response = ServicedeskplusApi::get('requests/111'); var_dump($response->request);
Common Usage
Create and use an instance of a class ServicedeskplusApi instead of Facade:
require 'vendor/autoload.php'; use Onbalt\ServicedeskplusApi\ServicedeskplusApi; $config = [ 'api_base_url' => 'http://helpdesk.local/api/v3/', 'technician_key' => 'YOUR_TECHNICIAN_KEY', 'api_version' => '3', 'api_v1_format' => 'json', 'timeout' => 60, ]; $sdpApi = new ServicedeskplusApi($config); // View Request $response = $sdpApi->get('requests/111'); var_dump($response->request);
Examples
View Request
See: http://ui.servicedeskplus.com/APIDocs3/index.html#view-request
$response = ServicedeskplusApi::get('requests/111'); var_dump($response);
object(stdClass)# (2) { ["request"]=> object(stdClass)# (50) { //<all request properties in V3 format> //@see: http://ui.servicedeskplus.com/APIDocs3/index.html#request8 } ["response_status"]=> object(stdClass)# (2) { ["status_code"]=> int(2000) ["status"]=> string(7) "success" } }
View all Requests
See: http://ui.servicedeskplus.com/APIDocs3/index.html#view-all-requests
$inputData = ServicedeskplusApi::prepareJsonInputData([ 'list_info' => [ //@see: http://ui.servicedeskplus.com/APIDocs3/index.html#list-info 'row_count' => 10, //max 100 'start_index' => 1, 'sort_field' => 'id', 'sort_order' => 'asc', 'get_total_count' => true, 'search_criteria' => [ [ 'field' => 'site.name', 'condition' => 'eq', 'value' => 'MyCompany', ], ], ] ]); $response = ServicedeskplusApi::get('requests', $inputData); var_dump($response);
object(stdClass)# (3) { ["requests"]=> array(10) { [0]=> object(stdClass)# (15) { //<base request properties in V3 format> //@see: http://ui.servicedeskplus.com/APIDocs3/index.html#view-all-requests } [1]=> //<...> } ["response_status"]=> object(stdClass)# (2) { ["status_code"]=> int(2000) ["status"]=> string(7) "success" }, ["list_info"]=> object(stdClass)# (8) { ["has_more_rows"]=> bool(true) ["get_total_count"]=> string(7) "true" ["total_count"]=> int(111) //<other source properties from $inputData's 'list_info' array> } }
Add new Request
See: http://ui.servicedeskplus.com/APIDocs3/index.html#add-request
$inputData = ServicedeskplusApi::prepareJsonInputData([ 'request' => [ 'subject' => 'Subject of the request', 'description' => 'HTML description of the request. Contains formatted text.', 'requester' => [ 'name' => 'Dummy Requester', 'email_id' => 'dummy.requester@dummy.com', ], 'site' => [ 'name' => 'Requester Company', ], 'impact' => [ 'name' => 'High', ], 'urgency' => [ 'name' => 'High', ], 'level' => [ 'name' => 'Tier 1', ], 'mode' => [ 'name' => 'Web Form', ], ] ]); $workorder = ServicedeskplusApi::post('requests', null, $inputData); var_dump($workorder->request->id); //int(112)
Add Attachment
See: Attachment / Add Attachment at http://beta.servicedeskplusmsp.com/SetUpWizard.do?forwardTo=apidoc&username=demo&password=demo
$inputData = ServicedeskplusApi::prepareJsonInputData([ 'attachment' => [ 'request' => [ 'id' => 112, ], ] ]); $filesData['multipart'] = [[ 'name' => 'file0', 'contents' => fopen('/full/path/to/file.ext', 'r'), 'filename' => 'file.ext', ]]; $response = ServicedeskplusApi::post('attachments', $inputData, $filesData); var_dump($response);
object(stdClass)# (2) { ["response_status"]=> object(stdClass)# (2) { ["status_code"]=> int(2000) ["status"]=> string(7) "success" } ["attachment"]=> object(stdClass)# (4) { ["id"]=> int(101) ["file_name"]=> string(7) "file.ext" ["content_url"]=> string(7) "/api/v3/attachments/101" ["size"]=> string(7) "2.42KB" } }
Credits
License
The MIT License (MIT). Please see License File for more information.
onbalt/servicedeskplus-api 适用场景与选型建议
onbalt/servicedeskplus-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 135 次下载、GitHub Stars 达 7, 最近一次更新时间为 2019 年 07 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「SDP」 「servicedeskplus」 「manageengine」 「sdpapi」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 onbalt/servicedeskplus-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 onbalt/servicedeskplus-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 onbalt/servicedeskplus-api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
AI integration package for SDP CMS Builder
A PHP library for parsing and generating SDP (Session Description Protocol).
A pluf module to sell digital products
Alfabank REST API integration
Session Description Protocol (SDP) Library for PHP
An encapsulation of the Safaricom SDP platform eg premium sms (MT and MO), bulk sms et al
统计信息
- 总下载量: 135
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-07-30