How to get Toky agents list
Learn how to get a list of your Toky agents using our API
API Endpoint used
Parameters you need to replace in the getTokyAgents function:
- [[TOKY_API_KEY]]: You can get the Toky API on this link: https://app.toky.co/business/my_account#api-key
function getTokyAgents()
{
// create a new cURL resource
$ch = curl_init();
$api_key = '[[TOKY_API_KEY]]';
$headers = array();
$headers[] = "X-Toky-Key: {$api_key}";
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "https://api.toky.co/v1/agents");
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
$curl_response = curl_exec($ch); // Send request
curl_close($ch); // close cURL resource
return json_decode($curl_response,true);
}
$agents = getTokyAgents();
$agentsNumber = sizeof($agents);
print "Loaded $agentsNumber agents: "; var_export($agents);
Updated almost 5 years ago