Hello guys,
$password = "password";
$key = "api key"; // (This parameter is used?)
$urltopost = "https://my_portal.freshdesk.com/helpdesk/tickets.xml";
$datatopost = "
<helpdesk_ticket>
<description>Ticket test API!!!</description>
<subject>Test ticket creation api</subject>
<email>email_user@mail.com</email>
<priority>1</priority>
<status-name>Open</status-name>
<status>2</status>
<source>3</source>
</helpdesk_ticket>";
$ch = curl_init ($urltopost);
//curl_setopt($ch, CURLOPT_POST, true); // (This parameter is used?)
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_USERPWD, "$email:$password");
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/xml"));
curl_setopt($ch, CURLOPT_POSTFIELDS, $datatopost);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); // (This parameter is used?)
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // (This parameter is used?)
curl_setopt($ch, CURLOPT_KEYPASSWD, $key);
$returndata = curl_exec($ch);
echo "<pre>"; print_r ($returndata); echo "</pre>";
?>