this is the php i have on my site.
its is called from an ajax call, but should give you what you need
my-open.php is just a modified open.php
( i just removed the header and footer includes)
<?php
set_include_path('/home/my/html/inc');
require_once 'functions.php';
header("Content-Type: application/json; charset=utf-8");
$name = sanitize($_POST);
$email = $_POST;
$subject = sanitize($_POST);
$message = sanitize($_POST);
$fields = array(
'name'=>urlencode($name),
'email'=>urlencode($email),
'phone'=>urlencode($_POST),
'topicId'=>'1',
'subject'=>urlencode($subject),
'message'=>urlencode($message)
);
$fields_string='';
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string,'&');
$url = "http://osticket.server/my-open.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_USERAGENT,API-HASH);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST,count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS,$fields_string);
// Set so curl_exec returns the result instead of outputting it.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Get the response and close the channel.
$response = curl_exec($ch);
curl_close($ch);
$newticket = intval($response);
if ( $newticket > 0 ){
echo json_encode( array("status" => "success", 'ticket' => $newticket) );
}else{
echo json_encode( array("status" => "error", 'message' => "Ticket Creation Failed. Please try again later") );
}
?>