Jump to content

Hooks on OpenTicket


Snapwp

Recommended Posts

Hey Everyone, 

 

I'm been working on a Open ticket hook. It's quite simple when a ticket is opened It should send off a curl request to my own api to then use a third twillo to call someone on call. 

 

The issue is that for some the PHP code works find when trigger this manally for the WHMCS hook won't trigger. 

 

 

<?php
add_hook('TicketOpen', 1, function($vars){

  $curl_handle=curl_init();
  curl_setopt($curl_handle,CURLOPT_URL,'http://snappyhost.co.uk/api-test.php');
  curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,5);
  curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
  $buffer = curl_exec($curl_handle);
  curl_close($curl_handle);
  if (empty($buffer)){
      print "Nothing returned from url.<p>";
  }
  else{
            $file = 'call.log';
$message = $buffer;
file_put_contents($file, $message, FILE_APPEND);
  }

add_hook('TicketUserReply', 2, function($vars) {
  
      $curl_handle=curl_init();
  curl_setopt($curl_handle,CURLOPT_URL,'http://snappyhost.co.uk/api-test.php');
  curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,5);
  curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
  $buffer = curl_exec($curl_handle);
  curl_close($curl_handle);
  if (empty($buffer)){
      print "Nothing returned from url.<p>";
  }
  else{
      $file = 'logs/call.log';
$message = $buffer;
file_put_contents($file, $message, FILE_APPEND);
  }
    
});

 

Any help with why this may not trigger would be great!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated