URL to api/task/cron e.g # http://yourdomain.com/support/api/tickets.json # key => API's Key (see admin panel on how to generate a key) # $data add custom required fields to the array. # # Originally authored by jared@osTicket.com # Modified by ntozier@osTicket / tmib.net //DIRECCIÓN DEL TICKET Y LA CLAVE DE API $config = array( 'url'=>'http://"IP:port"/ost/upload/api/tickets.json', 'key'=>'fake-api-key' ); $data = array( 'email' => $_POST["correo"], //CORREO 'subject' => $_POST["resumen"], //TITULO 'message' => $_POST["problema"], //MENSAJE 'ip' => $_SERVER['REMOTE_ADDR'], //IP CLIENTE 'topicId' => '58', //TOPIC //CAMPOS PERSONALIZADO 'cliente' => $_POST["cliente"], 'norden' => $_POST["norden"], 'encaminar' => $_POST["encaminar"], 'pinmaq' => $_POST["pinmaq"], 'attachments' => array() //ARRELGO PARA ARCHIVOS ); foreach ($_FILES as $file => $f){ if (isset($f) && is_uploaded_file($f['tmp_name'])) { $nombre = $f["name"]; $tipo = $f["type"]; $ruta = $f['tmp_name']; $data['attachments'][] = array("$nombre" => 'data: '.$tipo.';base64,'.base64_encode(file_get_contents($ruta))); } } function_exists('curl_version') or die('CURL support required'); function_exists('json_encode') or die('JSON support required'); set_time_limit(30); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $config['url']); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($ch, CURLOPT_USERAGENT, 'osTicket API Client v1.8'); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Expect:', 'X-API-Key: '.$config['key'])); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_TIMEOUT, 180); $result=curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($code != 201) die('Error al generar el ticket: '.$result); $ticket_id = (int) $result; ?>