在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:zendesk/zendesk_api_client_php开源软件地址:https://github.com/zendesk/zendesk_api_client_php开源编程语言:PHP 98.8%开源软件介绍:Zendesk PHP API Client LibraryAPI Client VersionThis is the second version of our PHP API client. The previous version of the API client can be found on the v1 branch. API version supportThis client only supports Zendesk's API v2. Please see our API documentation for more information. Requirements
InstallationThe Zendesk PHP API client can be installed using Composer. ComposerTo install run Upgrading from V1 to V2If you are upgrading from v1 of the client, we've written an upgrade guide to highlight some of the key differences. ConfigurationConfiguration is done through an instance of // load Composer
require 'vendor/autoload.php';
use Zendesk\API\HttpClient as ZendeskAPI;
$subdomain = "subdomain";
$username = "[email protected]"; // replace this with your registered email
$token = "6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv"; // replace this with your token
$client = new ZendeskAPI($subdomain);
$client->setAuth('basic', ['username' => $username, 'token' => $token]); UsageBasic Operations// Get all tickets
$tickets = $client->tickets()->findAll();
print_r($tickets);
// Get all tickets regarding a specific user.
$tickets = $client->users($requesterId)->tickets()->requested();
print_r($tickets);
// Create a new ticket
$newTicket = $client->tickets()->create([
'subject' => 'The quick brown fox jumps over the lazy dog',
'comment' => [
'body' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, ' .
'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
],
'priority' => 'normal'
]);
print_r($newTicket);
// Update a ticket
$client->tickets()->update(123,[
'priority' => 'high'
]);
// Delete a ticket
$client->tickets()->delete(123);
// Get all users
$users = $client->users()->findAll();
print_r($users); Attachments$attachment = $client->attachments()->upload([
'file' => getcwd().'/tests/assets/UK.png',
'type' => 'image/png',
'name' => 'UK.png' // Optional parameter, will default to filename.ext
]); Attaching files to comments $ticket = $client->tickets()->create([
'subject' => 'The quick brown fox jumps over the lazy dog',
'comment' => [
'body' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, ' .
'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'uploads' => [$attachment->upload->token]
]
]); Side-loadingSide-loading allows you to retrieve related records as part of a single request. See [the documentation] for more information. (https://developer.zendesk.com/rest_api/docs/core/side_loading). An example of sideloading with the client is shown below. $tickets = $client->tickets()->sideload(['users', 'groups'])->findAll(); PaginationThe Zendesk API offers a way to get the next pages for the requests and is documented in the Zendesk Developer Documentation. The way to do this is to pass it as an option to your request. $tickets = $this->client->tickets()->findAll(['per_page' => 10, 'page' => 2]); The allowed options are
Retrying RequestsAdd the
Available optionsOptions are passed on
ContributingPull Requests are always welcome but before you send one please read our contribution guidelines. It would speed up the process and would make sure that everybody follows the community's standard. DebuggingTo help would be contributors, we've added a REPL tool. It is a simple wrapper for psysh and symfony's console.
On your terminal, run Copyright and licenseCopyright 2013-present Zendesk Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论