Search Function in ZenDesk php api -
hello want create simple php if function in php search in zendesk specific user open ticket if system add message comment opened ticket if not system create ticket on behalf of user.
here code i'm using found on blog (i'm complete newbie)
// begin search open tickets on zendesk $zendesk = new zendesk(zd_apikey, zd_user, zd_site); $data = $zendesk->call("/search.json?query=status<solved requester:a#3b4edcfgiyfms3bbgzeszjl3drdx1y1ikgffxn7zyattij6wehup6wkorkfgozlvnb5@email.email type:ticket", $create, "get"); if ($data->results) { $ticket_id = (string) $data->results[0]->id; //use end-user's email address, not agent's email address case other api end-points. $user_email = 'a#3b4edcfgiyfms3bbgzeszjl3drdx1y1ikgffxn7zyattij6wehup6wkorkfgozlvnb5@email.email'; $zendesk = new zendesk(zd_apikey, $user_email, zd_site); $update = json_encode( array( 'request' => array( 'comment' => array( 'body' => $message, ) ) )); $data = $zendesk->call("/requests/" . $ticket_id . ".json", $update, "put"); }else{ $zendesk = new zendesk($apikey, $user, $subdomain, $suffix = '.json', $test = false); $arr = array("z_subject"=>substr($message, 6, 80), "z_description"=>substr($message, 6, 500), "z_recipient"=>"hello "."@email.email", "z_name"=>"$address", "z_requester"=>substr($address, 4, 80)."@email.email" ); $create = json_encode(array('ticket' => array('subject' => $arr['z_subject'], 'description' => $arr['z_description'], 'requester' => array('name' => $arr['z_name'], 'email' => $arr['z_requester']))), json_force_object); $data = $zendesk->call("/tickets", $create, "post"); $logger->writelog('end of ticket'); }
how ever when there open ticket user create ticket without adding message comment on zendesk
am missing here?
Comments
Post a Comment