Created
June 30, 2014 19:12
-
-
Save devinrader/9d272306903528ef2cc8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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