Search and return JSON for open tickets.
curl -X GET https://subdomain.zendesk.com/api/v2/search.json \
-H "Accept: application/json" \
--data-urlencode "query=type:ticket status:open" \
-u zendesk_email:zendesk_password
use chilkat();
$rest = chilkat::CkRest->new();
# URL: https://subdomain.zendesk.com/api/v2/search.json
$bTls = 1;
$port = 443;
$bAutoReconnect = 1;
$success = $rest->Connect("subdomain.zendesk.com",$port,$bTls,$bAutoReconnect);
if ($success != 1) {
print "ConnectFailReason: " . $rest->get_ConnectFailReason() . "\r\n";
print $rest->lastErrorText() . "\r\n";
exit;
}
$rest->SetAuthBasic("zendesk_email","zendesk_password");
$rest->AddQueryParam("query","type:ticket status:open");
$rest->AddHeader("Accept","application/json");
$strResponseBody = $rest->fullRequestFormUrlEncoded("GET","/api/v2/search.json");
if ($rest->get_LastMethodSuccess() != 1) {
print $rest->lastErrorText() . "\r\n";
exit;
}
$respStatusCode = $rest->get_ResponseStatusCode();
if ($respStatusCode >= 400) {
print "Response Status Code = " . $respStatusCode . "\r\n";
print "Response Header:" . "\r\n";
print $rest->responseHeader() . "\r\n";
print "Response Body:" . "\r\n";
print $strResponseBody . "\r\n";
exit;
}
$jsonResponse = chilkat::CkJsonObject->new();
$jsonResponse->Load($strResponseBody);
$facets = $jsonResponse->stringOf("facets");
$next_page = $jsonResponse->stringOf("next_page");
$previous_page = $jsonResponse->stringOf("previous_page");
$count = $jsonResponse->IntOf("count");
$i = 0;
$count_i = $jsonResponse->SizeOfArray("results");
while ($i < $count_i) {
$jsonResponse->put_I($i);
$url = $jsonResponse->stringOf("results[i].url");
$id = $jsonResponse->IntOf("results[i].id");
$external_id = $jsonResponse->stringOf("results[i].external_id");
$viaChannel = $jsonResponse->stringOf("results[i].via.channel");
$viaSourceRel = $jsonResponse->stringOf("results[i].via.source.rel");
$created_at = $jsonResponse->stringOf("results[i].created_at");
$updated_at = $jsonResponse->stringOf("results[i].updated_at");
$type = $jsonResponse->stringOf("results[i].type");
$subject = $jsonResponse->stringOf("results[i].subject");
$raw_subject = $jsonResponse->stringOf("results[i].raw_subject");
$description = $jsonResponse->stringOf("results[i].description");
$priority = $jsonResponse->stringOf("results[i].priority");
$status = $jsonResponse->stringOf("results[i].status");
$recipient = $jsonResponse->stringOf("results[i].recipient");
$requester_id = $jsonResponse->IntOf("results[i].requester_id");
$submitter_id = $jsonResponse->IntOf("results[i].submitter_id");
$assignee_id = $jsonResponse->IntOf("results[i].assignee_id");
$organization_id = $jsonResponse->IntOf("results[i].organization_id");
$group_id = $jsonResponse->IntOf("results[i].group_id");
$forum_topic_id = $jsonResponse->stringOf("results[i].forum_topic_id");
$problem_id = $jsonResponse->stringOf("results[i].problem_id");
$has_incidents = $jsonResponse->BoolOf("results[i].has_incidents");
$is_public = $jsonResponse->BoolOf("results[i].is_public");
$due_at = $jsonResponse->stringOf("results[i].due_at");
$satisfaction_rating = $jsonResponse->stringOf("results[i].satisfaction_rating");
$brand_id = $jsonResponse->IntOf("results[i].brand_id");
$allow_channelback = $jsonResponse->BoolOf("results[i].allow_channelback");
$result_type = $jsonResponse->stringOf("results[i].result_type");
$j = 0;
$count_j = $jsonResponse->SizeOfArray("results[i].collaborator_ids");
while ($j < $count_j) {
$jsonResponse->put_J($j);
$j = $j + 1;
}
$j = 0;
$count_j = $jsonResponse->SizeOfArray("results[i].follower_ids");
while ($j < $count_j) {
$jsonResponse->put_J($j);
$j = $j + 1;
}
$j = 0;
$count_j = $jsonResponse->SizeOfArray("results[i].email_cc_ids");
while ($j < $count_j) {
$jsonResponse->put_J($j);
$j = $j + 1;
}
$j = 0;
$count_j = $jsonResponse->SizeOfArray("results[i].tags");
while ($j < $count_j) {
$jsonResponse->put_J($j);
$strVal = $jsonResponse->stringOf("results[i].tags[j]");
$j = $j + 1;
}
$j = 0;
$count_j = $jsonResponse->SizeOfArray("results[i].custom_fields");
while ($j < $count_j) {
$jsonResponse->put_J($j);
$j = $j + 1;
}
$j = 0;
$count_j = $jsonResponse->SizeOfArray("results[i].sharing_agreement_ids");
while ($j < $count_j) {
$jsonResponse->put_J($j);
$j = $j + 1;
}
$j = 0;
$count_j = $jsonResponse->SizeOfArray("results[i].fields");
while ($j < $count_j) {
$jsonResponse->put_J($j);
$j = $j + 1;
}
$j = 0;
$count_j = $jsonResponse->SizeOfArray("results[i].followup_ids");
while ($j < $count_j) {
$jsonResponse->put_J($j);
$j = $j + 1;
}
$i = $i + 1;
}
{
"results": [
{
"url": "https://chilkat.zendesk.com/api/v2/tickets/4.json",
"id": 4,
"external_id": null,
"via": {
"channel": "web",
"source": {
"from": {},
"to": {},
"rel": null
}
},
"created_at": "2018-04-14T21:06:06Z",
"updated_at": "2018-04-14T21:06:06Z",
"type": "incident",
"subject": "Fix bug in software",
"raw_subject": "Fix bug in software",
"description": "Fix a bug in the software...",
"priority": "urgent",
"status": "open",
"recipient": null,
"requester_id": 361801727573,
"submitter_id": 361801727573,
"assignee_id": 361801727573,
"organization_id": 360015071793,
"group_id": 360000681553,
"collaborator_ids": [
],
"follower_ids": [
],
"email_cc_ids": [
],
"forum_topic_id": null,
"problem_id": null,
"has_incidents": false,
"is_public": true,
"due_at": null,
"tags": [
"bug"
],
"custom_fields": [
],
"satisfaction_rating": null,
"sharing_agreement_ids": [
],
"fields": [
],
"followup_ids": [
],
"brand_id": 360000471533,
"allow_channelback": false,
"result_type": "ticket"
},
{
"url": "https://chilkat.zendesk.com/api/v2/tickets/3.json",
"id": 3,
"external_id": null,
"via": {
"channel": "web",
"source": {
"from": {},
"to": {},
"rel": null
}
},
"created_at": "2018-04-14T21:03:21Z",
"updated_at": "2018-04-14T21:03:21Z",
"type": "task",
"subject": "Add cool new feature.",
"raw_subject": "Add cool new feature.",
"description": "Add a cool new feature to the product.",
"priority": "high",
"status": "open",
"recipient": null,
"requester_id": 361801727573,
"submitter_id": 361801727573,
"assignee_id": 361801727573,
"organization_id": 360015071793,
"group_id": 360000681553,
"collaborator_ids": [
],
"follower_ids": [
],
"email_cc_ids": [
],
"forum_topic_id": null,
"problem_id": null,
"has_incidents": false,
"is_public": true,
"due_at": "2018-04-18T17:00:00Z",
"tags": [
"cool",
"feature"
],
"custom_fields": [
],
"satisfaction_rating": null,
"sharing_agreement_ids": [
],
"fields": [
],
"followup_ids": [
],
"brand_id": 360000471533,
"allow_channelback": false,
"result_type": "ticket"
},
{
"url": "https://chilkat.zendesk.com/api/v2/tickets/1.json",
"id": 1,
"external_id": null,
"via": {
"channel": "sample_ticket",
"source": {
"from": {},
"to": {},
"rel": null
}
},
"created_at": "2018-04-14T19:01:56Z",
"updated_at": "2018-04-14T19:01:57Z",
"type": "incident",
"subject": "Sample ticket: Meet the ticket",
"raw_subject": "Sample ticket: Meet the ticket",
"description": "Hi Matt,\n\nEmails, chats, voicemails, and tweets are captured in Zendesk Support as tickets. Start typing above to respond and click Submit to send. To test how an email becomes a ticket, send a message to support@chilkat.zendesk.com.\n\nCurious about what your customers will see when you reply? Check out this video:\nhttps://demos.zendesk.com/hc/en-us/articles/202341799\n",
"priority": "normal",
"status": "open",
"recipient": null,
"requester_id": 361809055094,
"submitter_id": 361801727573,
"assignee_id": 361801727573,
"organization_id": null,
"group_id": 360000681553,
"collaborator_ids": [
],
"follower_ids": [
],
"email_cc_ids": [
],
"forum_topic_id": null,
"problem_id": null,
"has_incidents": false,
"is_public": true,
"due_at": null,
"tags": [
"sample",
"support",
"zendesk"
],
"custom_fields": [
],
"satisfaction_rating": null,
"sharing_agreement_ids": [
],
"fields": [
],
"followup_ids": [
],
"brand_id": 360000471533,
"allow_channelback": false,
"result_type": "ticket"
}
],
"facets": null,
"next_page": null,
"previous_page": null,
"count": 3
}