I have a WordPress site where I am using a plugin called Formidable Forms. I have created this form and used an action hook to post to the osTicket API, which works with the exception of attachments. The attachments are uploaded to a Amazon S3 bucket before the form is submitted. Every time a ticket is created, there is no attachment. I did error checking and haven't come up with anything. When you've been looking at code for hours, you need an extra pair of eyes to see what you are doing wrong. Any help is greatly appreciated. Below is the attachment portion of my code.    if ($form_id == 11) {        $debug = "0";        $config = array(            'url' => 'https://example.com/api/tickets.json', // URL to site.tld/api/tickets.json            'key' => 'secretykeypslsiw'  // API Key goes here        );        $attachArray = array();        for ($i = 0; $i < count($_FILES); $i++) {            $name = $_FILES;            $type = mime_content_type($_FILES);        }                $month = date('m');        $day = date('d');                for($x=0;$x<count($name);$x++) {            $attachArray = array( $name => "data:$type;base64;" . base64_encode(file_get_contents("https://s3.amazonaws.com/my-assets/wp-content/uploads/$month/$day/$name")) );        }        $data = array(            'attachments' => $attachArray        );    }

I honestly have no idea if the ticket api works with the s3 plugin... I've never tried.  Maybe someone else can assist you on this, I'm afraid I wont be much assistance.

Not a problem. But does the rest of the code look pretty legit for multiple attachments? I think it will definitely work with s3; I think the problem is $_FILES. Which has nothing to do with osTicket. On my end, I just need to figure out why it is return null.

The rest of it looks pretty good to me.

4 years later


I keep getting Valid API key required, yet I have copy and pasted and works when sending data via python.


Any help would be appreciated.

@opoihiknsk
This thread is 4 years old and I doubt for the same version that you are running.
Please help us to help you by reading and following the posting guidelines located in this thread: Please read before requesting assistance. The more information you give us the better we will be able to assist you. Thank you.

Killing zombie thread with a head shot.

Write a Reply...