0

I am trying to create a Freshdesk ticket using freshdesk API in php curl. followed this documentation link https://github.com/freshdesk/fresh-samples/tree/master/php_samples But it is not creating ticket

    <?php
$fd_domain = "http://test.freshdesk.com";
$token = "apikey";
$password = "xxx";
$email = "aaa@bbb.com";
$data = array(
    "helpdesk_ticket" => array(
        "description" => "Some details on the issue ...",
        "subject" => "TEST Support needed..",
        "email" => "tom@outerspace.com",
        "priority" => 1,
        "status" => 2
    ),
    "cc_emails" => "ram@freshdesk.com,diana@freshdesk.com"
);
$json_body = json_encode($data, JSON_FORCE_OBJECT | JSON_PRETTY_PRINT);
$header[] = "Content-type: application/json";
$connection = curl_init("$fd_domain/helpdesk/tickets.json");
curl_setopt($connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($connection, CURLOPT_HTTPHEADER, $header);
curl_setopt($connection, CURLOPT_HEADER, false);
curl_setopt($connection, CURLOPT_USERPWD, "$email:$password");
curl_setopt($connection, CURLOPT_POST, true);
curl_setopt($connection, CURLOPT_POSTFIELDS, $json_body);
curl_setopt($connection, CURLOPT_VERBOSE, 1);
$response = curl_exec($connection);
echo $response;
?>

when i run this file in terminal as php file.php But ticket is not running, I am getting the following console results But I am not sure what is happening.

* Hostname was NOT found in DNS cache
*   Trying 107.22.197.253...
* Connected to test.freshdesk.com (107.22.197.253) port 80 (#0)
* Server auth using Basic with user 'aaa@bbb.com'
> POST /helpdesk/tickets.json HTTP/1.1
Authorization: Basic bW9oYW5Ad2h5YWJsZS5jb206bW9oYW4xMjM=
Host: test.freshdesk.com
Accept: */*
Content-type: application/json
Content-Length: 274

* upload completely sent off: 274 out of 274 bytes
< HTTP/1.1 302 Found
< Cache-Control: no-cache
< Content-Type: text/html; charset=utf-8
< Location: https://test.freshdesk.com/helpdesk/tickets.json
< Set-Cookie: helpdesk_node_session=0fbdb53a62fff9b78f57d069a7abfde86bef1e16eefa8710dbcadb99a1723a3a42affa906dd23ceb6e77f20f0a0e703a2cb6d3423cb94ec074f0006dadfe4b02; path=/
< Set-Cookie: _helpkit_session=BAh7CDoPc2Vzc2lvbl9pZCIlMzdmNGI4ZDZkZWMxNmRhNDBkYWI1ZTFiODU2NDFkODhJIhV1c2VyX2NyZWRlbnRpYWxzBjoGRUZJIgGAZmYxMmExZWJjZGFiMTlkMjgxYjlkYmI0NjIwZjdhMjFlYTgxM2YyZWE5M2UzYTk0MTlhYzBhNDA2M2QyMzEwNTdmNDQ4NjVjYmE1MjA1ZjU2ODUzNGI2ZGQ4NTExZjljZGUyZGQxNzViMzNjMzhkZTYxMTc1MDRkMWE2MGMyOTEGOwZUSSIYdXNlcl9jcmVkZW50aWFsc19pZAY7BkZsKwj%2B0TIqAQA%3D--fdc65abdf0bdcf0c38db4837f05b19050ef1a2f0; path=/; HttpOnly
< Status: 302
< X-Runtime: 25
< Content-Length: 117
< Connection: keep-alive
< 
* Connection #0 to host test.freshdesk.com left intact
<html><body>You are being <a href="https://test.freshdesk.com/helpdesk/tickets.json">redirected</a>.</body></html>

please some help me

Guido Leenders
  • 4,232
  • 1
  • 23
  • 43
doing007
  • 1
  • 1
  • 4
  • Can you try adding https? http://freshdesk.com/api#endpoint_ssl – Subhash Chandran Dec 18 '14 at 05:49
  • @subhash , It is working after adding https:// . Thanks you so much for your answer. – doing007 Dec 19 '14 at 19:06
  • Perhaps I'm a little late, but I've created a PHP wrapper for the freshdesk-rest API. It's on [github](https://github.com/EVODelavega/freshdesk-rest) and easily installed using composer. Freshdesk knows about the package, and links to it in their documentation (fresh-samples > third party > PHP). It can create tickets easily – Elias Van Ootegem Apr 24 '15 at 11:59

0 Answers0