I'd like to use the FreshDesk API, say, the 'create a ticket' command.
I have used POST cUrl before, but the example given there confuses me and I am not quite sure how to concretely make a cUrl call as provided there,
curl -u user@yourcompany.com:test -H "Content-Type: application/json" -d '{ "helpdesk_ticket": { "description": "Details about the issue...", "subject": "Support Needed...", "email": "tom@outerspace.com", "priority": 1, "status": 2 }, "cc_emails": "ram@freshdesk.com,diana@freshdesk.com" }' -X POST http://domain.freshdesk.com/helpdesk/tickets.json
I noticed this is a shell command, and I do not have access to shell commands.
However, I have successfully been able to use cUrl POST API's before (with Disqus).
There, API calls would look like
$thread = "param1";
$remote_auth_s3 = "param2";
$forum = "param3";
$api = "param4";
$url = 'http://disqus.com/api/3.0/posts/create.json';
$fields = array(
'api_secret'=>urlencode($api),
'thread'=>urlencode($thread),
'remote_auth'=>urlencode($remote_auth_s3),
'message'=>urlencode($message)
);
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string,'&');
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
$results = json_decode($result, true);
if ($results === NULL) die('Error parsing json');
This seemed all very logical, but how am I supposed to convert the shell command to this format of a cUrl call?
This might be a very stupid question, but also a honest one. I did find two others with the same problem, but they did not need to also include POST Parameters, so please don't mark this as a duplicate.
I hope someone is able to solve my dilemma.