Simple php cURL function for SupportBee API

Simple php cURL function for SupportBee API

There are a ton of support/user issue apps and websites out there. At an old job we used SupportBee  for all of our client support requests.

I started built out a dashboard that will merge all of our third party services to one easy to read page, sorted by client. Thankfully most of the third party services we use have great API’s and SupportBee is no different.

For my purposes I needed to create a simple php script that would have the ability to search their API in a variety of different ways. Here is the code I decided to implement.

function SupportBeeGet( $url = null ) {
        $auth = %YOUR API TOKEN%;
        $base = %YOUR BASE URL%;

        if ( $url == null ) {
                $url = '/tickets/?archived=false'; //the api end point
        }

        $url = $base. $url . '&auth_token=' . $auth;

        $curl = curl_init();

        // Set curl options
        curl_setopt($curl, CURLOPT_HEADER, false);
        curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_URL, $url);

        $a = curl_exec($curl);
        curl_close($curl);

        return json_decode($a);
}

As you can see it is pretty straightforward and allows for any API request by proving the $url variable.

Hopefully this helps you get started with the SupportBee API.