Page 1 of 1

Submit a new task from extrenal script

Posted: Tue May 10, 2016 7:23 am
by scz
Script URL:
Version of script:
Hosting company:
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution:

Write your message below:

Hello. I have need to create new ticket from a PHP script. In hesk configuration there is enabled option to generate and needed captcha number http://staff.fundacjamiastasportu.pl/he ... .php?54451, so use this script is impossible for this.

What changes should I do in "index.php?a=add" script to allow submit taks from external PHP script without user interaction?
For example I may add some alternative secret key parameter in URL that hesk recvovery that this is accepted script.

Best regards
Sebastian

Re: Submit a new task from extrenal script

Posted: Tue May 10, 2016 12:00 pm
by Klemen
The easiest way would with no need to change anything would be to send an email and convert the email to ticket using email piping or pop3 fetching.

Modifying the submit_ticket.php is out of the scope of my support and might cause all kinds of problems, you should probably hire a PHP developer to help you with that instead.

Re: Submit a new task from extrenal script

Posted: Fri May 13, 2016 5:41 pm
by scz
Yes, this is the easiest way, but at least functional. For some rison I would use functional as from form submit.

Edit: It is possible to use submit_ticket.php to use with cURL query. Here You have list of modification that file:

[1]
Copy original file to renamed (for example submit_ticket_for_curl.php)

[2]
Section: '// Try to detect some simple SPAM bots'
Action: comment all this IF block

[3]
Section: '// Check anti-SPAM question'
Action: comment all IF block

[4]
Section: '// Check anti-SPAM image'
Action: comment all IF block

[5]
Section: IF block if ($hesk_settings['confirm_email'])
Action: comment all IF block

[6]
Section: '// Need to notify staff?'
Action: change IF rule adding ' AND $_POST['notify_owner'] == 1'

[7]
Section: '// Need to notify staff?'
Action: change ELSEIF rule adding ' AND $_POST['notify_owner'] == 1'

[8]
Section: Your script
Action: Create function something like this:

Code: Select all

      function sendHelpdeskTicket ($address='submit_ticket_for_curl.php', $name, $subject, $message, $category=1, $priority=3, $notify_owner=1, $email = 'admin@example.com') {
         $arrPosts = Array (
               'name' => $name,
               'subject' => $subject,
               'email' => $email,
               'email2' => $email,
               'category' => $category,
               'priority' => $priority,
               'message' => $message,
               'notify_owner' => $notify_owner,
         );
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $address);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_HEADER, 0);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query ($arrPosts));
         curl_exec($ch);
         curl_close($ch);
      }
Of course You may add some yourself security mechanism, like secret code or IP filter

Re: Submit a new task from extrenal script

Posted: Fri May 13, 2016 7:04 pm
by Klemen
Thanks for sharing your solution!