Skip to content

Instantly share code, notes, and snippets.

@devinrader
Created June 30, 2014 19:12
Show Gist options
  • Save devinrader/9d272306903528ef2cc8 to your computer and use it in GitHub Desktop.
Save devinrader/9d272306903528ef2cc8 to your computer and use it in GitHub Desktop.
$client = new ZendeskAPI($subdomain, $username);
$client->setAuth('token', $token); // set either token or password
$search_query = "type:ticket status<solved order_by:updated_at sort:desc fieldvalue:" . $from;
try
{
$results = $client->search(array('query'=>$search_query));
if ( (int)$results->count > 0) {
$ticket = $results->results[0];
$ticket_id = (string) $ticket->id;
$client->ticket(array($ticket_id))->update(array(
'comment' => array(
'public' => true,
'body' => $body
)
));
}
else {
$newTicket = $client->tickets()->create(array (
'description' => $body,
'subject' => substr($body, 0, 80),
'requester_email' => $username,
'custom_fields' =>
array(
'id' => $ZD_FIELD,
'value' => $from
)
));
}
}
catch (Exception $e)
{
$debug = $client->getDebug();
echo $debug->lastResponseCode;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment