<?php

include "../../vendor/autoload.php";
use Zendesk\API\HttpClient as ZendeskAPI;
/**
 * Replace the following with your own.
 */
$subdomain = "subdomain";
$username = "******";
$token = "6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv";
$client = new ZendeskAPI($subdomain);
$client->setAuth('basic', ['username' => $username, 'token' => $token]);
try {
    // Query Zendesk API to retrieve the ticket details
    $id = 31;
    $tickets = $client->tickets()->find($id);
    // Show the results
    echo "<pre>";
    print_r($tickets->ticket);
    echo "</pre>";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
    echo 'Please check your credentials. Make sure to change the $subdomain, $username, and $token variables in this file.';
}
<?php

include "../../vendor/autoload.php";
use Zendesk\API\HttpClient as ZendeskAPI;
/**
 * Replace the following with your own.
 */
$subdomain = "subdomain";
$username = "******";
$token = "6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv";
$client = new ZendeskAPI($subdomain);
$client->setAuth('basic', ['username' => $username, 'token' => $token]);
try {
    // Update a new ticket
    $updateTicket = $client->tickets()->update(41, ['priority' => 'urgent', 'comment' => ['body' => 'We have changed your ticket priority to Urgent and will keep you up-to-date asap.']]);
    // Show result
    echo "<pre>";
    print_r($updateTicket);
    echo "</pre>";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
    echo 'Please check your credentials. Make sure to change the $subdomain, $username, and $token variables in this file.';
}
<?php

include "../../vendor/autoload.php";
use Zendesk\API\HttpClient as ZendeskAPI;
/**
 * Replace the following with your own.
 */
$subdomain = "subdomain";
$username = "******";
$token = "6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv";
$client = new ZendeskAPI($subdomain);
$client->setAuth('basic', ['username' => $username, 'token' => $token]);
try {
    // Get all tickets
    $tickets = $client->tickets()->findAll();
    // Show the results
    echo "<pre>";
    print_r($tickets);
    echo "</pre>";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
    echo 'Please check your credentials. Make sure to change the $subdomain, $username, and $token variables in this file.';
}
<?php

include "vendor/autoload.php";
use Zendesk\API\HttpClient as ZendeskAPI;
$subdomain = "subdomain";
$username = "******";
$token = "6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv";
// replace this with your token
//$password = "******";
$client = new ZendeskAPI($subdomain, $username);
$client->setAuth('token', $token);
// set either token or password
// Get all tickets
$tickets = $client->tickets()->findAll();
print_r($tickets);
// Create a new ticket
$newTicket = $client->tickets()->create(array('subject' => 'The quick brown fox jumps over the lazy dog', 'comment' => array('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 multiple tickets
$client->ticket(array(123, 456))->update(array('status' => 'urgent'));
// Delete a ticket
$client->ticket(123)->delete();
<?php

include "../../vendor/autoload.php";
use Zendesk\API\HttpClient as ZendeskAPI;
/**
 * Replace the following with your own.
 */
$subdomain = "subdomain";
$username = "******";
$token = "6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv";
$client = new ZendeskAPI($subdomain);
$client->setAuth('basic', ['username' => $username, 'token' => $token]);
try {
    // Query the Zendesk API to retrieve the ticket comments
    $id = 72;
    $tickets = $client->tickets($id)->comments()->findAll();
    // Show the results
    echo "<pre>";
    print_r($tickets);
    echo "</pre>";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
    echo 'Please check your credentials. Make sure to change the $subdomain, $username, and $token variables in this file.';
}
<?php

include "../../vendor/autoload.php";
use Zendesk\API\HttpClient as ZendeskAPI;
/**
 * Replace the following with your own.
 */
$subdomain = "subdomain";
$username = "******";
$token = "6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv";
$client = new ZendeskAPI($subdomain);
$client->setAuth('basic', ['username' => $username, 'token' => $token]);
try {
    // Delete a ticket by id
    $id = '51';
    $deleteTicket = $client->tickets()->delete($id);
    echo "Ticket ({$id}) has been removed";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
    echo 'Please check your credentials. Make sure to change the $subdomain, $username, and $token variables in this file.';
}
<?php

include "../../vendor/autoload.php";
use Zendesk\API\HttpClient as ZendeskAPI;
/**
 * Replace the following with your own.
 */
$subdomain = "subdomain";
$username = "******";
$token = "6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv";
$client = new ZendeskAPI($subdomain);
$client->setAuth('basic', ['username' => $username, 'token' => $token]);
try {
    // Create a new ticket wi
    $newTicket = $client->tickets()->create(array('type' => 'problem', 'tags' => array('demo', 'testing', 'api', 'zendesk'), 'subject' => 'The quick brown fox jumps over the lazy dog', 'comment' => array('body' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'), 'requester' => array('locale_id' => '1', 'name' => 'Example User', 'email' => '*****@*****.**'), 'priority' => 'normal'));
    // Show result
    echo "<pre>";
    print_r($newTicket);
    echo "</pre>";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
    echo 'Please check your credentials. Make sure to change the $subdomain, $username, and $token variables in this file.';
}