<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.smartsheet.com/2.0/users?includeAll=true");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Authorization: Bearer qJc6jnLsHoqznwCbkApNwLMQamt6ITcykpgen", 'Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = json_decode(curl_exec($ch));
curl_close($ch);

echo "<pre>";
print_r($response);
echo "</pre>";

$ssUsers = $response->data;
$btbUsers = $db->run("SELECT * FROM user WHERE clientId = 0");

foreach ( $btbUsers as $bu ) {
    foreach ( $ssUsers as $su ) {
        if ( $su->name == $bu['name'] ) {
            echo "match = ss: ".$su->name." (".$su->email."), btb: ".$bu['name']." (".$bu['email'].")<br>";
            if ( $su->email != $bu['email'] ) {
                echo "email mismatch: ".$su->name." (".$su->email."), btb: ".$bu['name']." (".$bu['email'].")<br>";
            }
        }
    }
}