dithidi/freshdesk-php-sdk

Freshdesk API (v2) 的 PHP SDK

0.3.4 2021-07-27 19:27 UTC

This package is not auto-updated.

Last update: 2024-09-29 13:28:15 UTC


README

Build Status Scrutinizer Code Quality SensioLabsInsight Packagist

这是一个适用于 Freshdesk API v2 的 PHP 5.5+ SDK。

如果您有任何问题,请与我联系或在 GitHub 上提交问题。

快速开始

require __DIR__ . '/vendor/autoload.php';
use \Freshdesk\Api;

$api = new Api("your_freshdesk_api_key", "your_freshdesk_domain");

$all = $api->tickets->all();
$some = $api->tickets->all(['page' => 2]);
$new = $api->tickets->create($data);
$updated = $api->tickets->update($data);
$api->tickets->delete($id);
$existing = $api->tickets->view($id);

//Responses are simple arrays, e.g.:
$id = $existing['id'];
$first = $all[0];

框架集成

安装

要将此库集成到您的应用程序中,请使用 Composer

mpclarkson/freshdesk-php-sdk 添加到您的 composer.json 文件

{
    "require": {
        "mpclarkson/freshdesk-php-sdk": "dev-master"
    }
}

然后运行

php composer.phar install

API 概述

完整的文档可在此处找到 这里

入门

创建新的 API 实例非常简单。您只需要您的 Freshdesk API 密钥和 Freshdesk 域名。

require __DIR__ . '/vendor/autoload.php';
use \Freshdesk\Api;

$api = new Api("your_freshdesk_api_key", "your_freshdesk_domain");

资源

每个资源的可用方法都可通过 api 的公共属性访问,例如

//Contacts
$contacts = $api->contacts->update($contactId, $data);

//Agents
$me = $api->agents->current();

//Companies
$company = $api->companies->create($data);

//Groups
$deleted = $api->groups->delete($groupId);

//Tickets
$ticket = $api->tickets->view($filters);

//Time Entries
$time = $api->timeEntries->all($ticket['id']);

//Conversations
$ticket = $api->conversations->note($ticketId, $data);

//Categories
$newCategory = $api->categories->create($data);

//Forums
$forum = $api->forums->create($categoryId, $data);

//Topics
$topics = $api->topics->monitor($topicId, $userId);

//Comments
$comment = $api->comments->create($forumId);

//Email Configs
$configs = $api->emailConfigs->all();

//Products
$product = $api->products->view($productId);

//Business Hours
$hours = $api->businessHours->all();

//SLA Policy
$policies = $api->slaPolicies->all();

响应

所有响应都是数据数组。请参阅 Freshdesk 的文档以获取更多信息。

过滤

所有 GET 请求都接受可选的 array $query 参数以过滤结果。例如

//Page 2 with 50 results per page
$page2 = $this->forums->all(['page' => 2, 'per_page' => 50]);

//Tickets for a specific customer
$tickets = $this->tickets->view(['company_id' => $companyId]);

请阅读 Freshdesk 文档以获取有关过滤 GET 请求的更多信息。

贡献

这是一个正在进行的工作,欢迎 PR。请阅读 贡献指南

几乎所有 API 调用都可用,但 解决方案调查 除外,因为 Freshdesk 尚未实现。

  • 解决方案
  • 调查
  • 上传文件尚不支持
  • 更多的测试。你永远都不嫌多!
  • 更好的文档

作者

该库由来自 HileniumMatthew Clarkson 编写和维护。

参考