Quantcast
Channel: Troubleshooting and Problems Discussions on osTicket Forums
Viewing all articles
Browse latest Browse all 568

Create Ticket API and Attachments

$
0
0
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['file141']['name']); $i++) {
            $name[] = $_FILES['file141']['name'][$i];
            $type[] = mime_content_type($_FILES['file141']['name'][$i]);
        }        
        $month = date('m');
        $day = date('d');        
        for($x=0;$x<count($name);$x++) {
            $attachArray = array( $name[$x] => "data:$type[$x];base64;" . base64_encode(file_get_contents("https://s3.amazonaws.com/my-assets/wp-content/uploads/$month/$day/$name[$x]")) );
        }

        $data = array(
            'attachments' => $attachArray
        );
    }

Viewing all articles
Browse latest Browse all 568

Latest Images

Trending Articles



Latest Images