PHP code example of mettleworks / desk-com-exporter

1. Go to this page and download the library: Download mettleworks/desk-com-exporter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mettleworks / desk-com-exporter example snippets

 

$deskUrl = 'https://YOUR-ACCOUNT.desk.com';
$email = '[email protected]';
$password = 'your-password';

$client = new \GuzzleHttp\Client([
    'base_uri' => $deskUrl,
    'auth' => [
        $email,
        $password
    ]
]);

$exporter = new \Mettleworks\DeskComExporter\DeskComExporter($client);

$caseList = [];

$exporter->fetchCases(function($cases) use(&$caseList)
{
    foreach($cases['_embedded']['entries'] as $entry)
    {
        $caseList[$entry['id']] = true;
    }

    var_dump(count($caseList));
});

$customerList = [];

$exporter->fetchCustomers(function($customers) use(&$customerList)
{
    foreach($customers['_embedded']['entries'] as $entry)
    {
        $customerList[$entry['id']] = true;
    }

    var_dump(count($customerList));
});