LoginSignup
4
4

More than 5 years have passed since last update.

Zendesk Rest APIメモ (PHP)

Posted at

ためしてちょいちょい追加します。

0. 準備

composer.json

{
  "require": {
    "zendesk/zendesk_api_client_php": "dev-master"
  }
}

install

$ composer install

1. 問い合わせ登録

<?php
require 'vendor/autoload.php';

use Zendesk\API\HttpClient as ZendeskAPI;

$subdomain = "xxx";
$username  = "xxx";
$token     = "xxx";

$client = new ZendeskAPI($subdomain, $username);
$client->setAuth('basic', ['username' => $username, 'token' => $token]);

// カスタムフィールド(任意)
// フィールドのIDはカスタムフィールドの詳細ページに表示されるIDを入れる
$custom_fields = array();
$custom_fields[] = array("id" => "27903658", "value" => "1234567"); // 注文番号
$custom_fields[] = array("id" => "27895577", "value" => "5678901"); // ○○ 番号

// 問い合わせした人情報
$requester = array(
  "name"  =>  "なまえ",
  "email" => "foo@example.com",
 );

$ticket = array(
  'subject'  => 'APIからのチケット登録テスト2',
  'comment'  => array(
    'body'   => "本文あああ\n2行目\n3行目"
   ),
  'priority'      => 'normal',
  'custom_fields' => $custom_fields,
  'requester'     => $requester,
);


$newTicket = $client->tickets()->create($ticket);
print_r($newTicket);

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4