This is the code I am trying:
$api_key = FRESH_DESK_API;
$password = FRESH_DESK_PASSWORD;
$yourdomain = FRESH_DESK_DOMAIN;
$getpaentdetails = $this->ss_aw_parents_model->get_parent_profile_detailsbyid($parent_id);
$parentemail = $getpaentdetails[0]->ss_aw_parent_email;
$contactdetailsary = $this->contact_details();
$userid = "";
foreach($contactdetailsary as $value)
{
if($value['email'] == $parentemail)
{
$userid = $value['id'];
}
}
$ticketid = $inputpost['ticket_id'];
$message = $inputpost['message'];
$ticket_data = json_encode(array(
"body" => $message,
"user_id" => $userid
));
$url = "https://$yourdomain.freshdesk.com/api/v2/tickets/$ticketid/reply";
$ch = curl_init($url);
$header[] = "Content-type: application/json";
$header[] = "Content-type: multipart/form-data";
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$api_key:$password");
curl_setopt($ch, CURLOPT_POSTFIELDS, $ticket_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
$info = curl_getinfo($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$headers = substr($server_output, 0, $header_size);
$response = substr($server_output, $header_size);
curl_close($ch);
if($info['http_code'] == 201){
$responseary['status'] = 200;
$responseary['msg'] = "Reply post successfully";
}
else{
$responseary['status'] = 500;
$responseary['error'] = $info;
$responseary['msg'] = "Reply post fail";
}
$userid is the customer id in freshdesk server. This is the user in our app.
api key is the only API key I get from my Profile in freshdesk account.
If that is admin API key, then as you mentioned I am not aware of any other API key. Can you please suggest where do I get that to post a reply as an user.
Thanks in Advance.