2 years later

I found this example worked OK, but with attachments it took way too long - like 30+ seconds, and since we are creating the ticket from a browser form, it made for a terrible user experience, looked like the server hung.

Rather than calling php curl, I used the curl command line from exec, creating a temporary file with the same $data as in the example above.

$json = json_encode($data);
$jsonfile = $_SERVER['DOCUMENT_ROOT'] . "/myfolder/ticket." . time() . ".json"; // temporary json file with data
file_put_contents($jsonfile, $json); // write json file
$curlcmd = 'curl -H "X-API-Key: ' . $ost_apikey .
'" --user-agent "osTicket API Client v1.8" --data @' . $jsonfile . ' ' . $ost_url . ' > /dev/null 2>&1 &' ;
exec ($curlcmd);

There is the downside that we don't handle errors, but its not like we are able to do anything useful if there is an error anyway.

Write a Reply...