I’ve managed to get my php curl integration running with our splynx server and can pull customer info, stats and view tickets.
However I have a challenge with the ticket creation and when including the header authorization
it reports an error that it is missing the auth header. Even though it is there.
I think im adding my array and auth header incorrectly for ticket creation.
Would some one be so kind as to point me in the right direction?
Is it an escape character, or other issue that I’m not seeing in the array?
Any help on the subject would be greatly appreciated.
Below is my code:
this is the error code I receive.
string(252) “{“error”:{“code”:500,“internal_code”:“SERVER_ERROR”,“message”:“Argument 1 passed to base\Model::load() must be of the type array, null given, called in /var/www/splynx/app/controllers/api/v2/admin/support/TicketsController.php on line 190”}}”
<?php
include '../API/SplynxApi.php';
$api_key = xxxxxxxxxxx';
$api_secret = 'xxxxxxxxxxxxxx';
$headers = array(
'Content-Type: application/json',
'Authorization: Basic '. base64_encode("$api_key:$api_secret")
);
$ch = curl_init();
#curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, "http://Y.Y.Y.Y/api/2.0/admin/support/tickets");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
'Authorization: Basic '. base64_encode("$api_key:$api_secret"),
"reporter_id\": \"5039\",
\"reporter_type\": \"customer\",
\"customer_id\": \"5039\",
\"incoming_customer_id\": \"0\",
\"hidden\": \"0\",
\"assign_to\": \"60\",
\"status_id\": \"4\",
\"group_id\": \"1\",
\"type_id\": \"2\",
\"task_id\": 0,
\"subject\": \"Jo's First Splynx Ticket\",
\"priority\": \"medium\",
\"star\": \"0"
));
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
?>