Tasks PHP Quick Start

Last updated: 2020-04-28 Contributors John WangByrne ReesePaco Vu
Edit this page

Welcome to the Engage Platform. In this Quick Start, we are going to help you get a list of tasks that can be assigned to agents within your account. Obtaining a reference to a task by its ID is an important first step in managing the workflow of that task. This Quick Start will have you up and running in minutes.

Obtain Access Key

The first thing you need to do is obtain an API Access Token if you do not already have one. Access tokens can be created and/or accessed via the "API access token" area in the "Admin" area of your Engage portal.

How to generate an Engage API access token
  1. Login to your Engage portal and click on the "Admin" menu located in the top, horizontal menu.

  2. Select "API access tokens" towards the bottom of the left hand menu.

  3. You should see a list of access tokens if any have been provisioned. Select the token, or click the "+" button to create a new one.

  4. Finally, enter a label/description for your token, and select an Agent on which the token will act on behalf of. Make sure the token is "enabled" and click "Save."

    API access token

Make note of the access token generated as you will need it later.

Create and Edit tasks.php

Create a file called tasks.php. Be sure to edit the variables in <ALL CAPS> with your app's credentials.

<?php
$SERVER = "https://<YOUR-DOMAIN>.api.engagement.dimelo.com";
$ACCESS_TOKEN = '<API-ACCESS-TOKEN>';
$API = "/1.0/tasks";

try {
    $url = $SERVER . $API;
    $headers = array (
          'Authorization: Bearer ' . $ACCESS_TOKEN
        );
    try {
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_TIMEOUT, 600);

        $strResponse = curl_exec($ch);
        $curlErrno = curl_errno($ch);
        if ($curlErrno) {
            throw new Exception($ecurlError);
        } else {
            $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
            curl_close($ch);
            if ($httpCode == 200) {
              print_r($strResponse."\n");
            }else{
              print_r($httpCode."\n");
            }
        }
    } catch (Exception $e) {
        throw $e;
    }
}catch (Exception $e) {
    throw $e;
}

Run Your Code

You are almost done. Now run your script.

$ php tasks.php

Need Help?

Having difficulty? Feeling frustrated? Receiving an error you don't understand? Our community is here to help and may already have found an answer. Search our community forums, and if you don't find an answer please ask!

Search the forums »

What's Next?

When you have successfully made your first API call, it is time to take your next step towards building a more robust Engage application.

Explore the REST API »