How to get Toky contacts list
Learn how to get a list of contacts from your Toky directory using our API
API Endpoint used
Parameters you need to replace in the getTokyContacts
function:
- [[TOKY_API_KEY]]: You can get the Toky API on this link: https://app.toky.co/business/my_account#api-key
<?php
function getTokyContacts(){
// 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/contacts");
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);
}
$contacts= getTokyContacts();
$contactsNumber = sizeof($contacts);
print "Loaded $contactsNumber contacts: "; var_export($contacts);
?>
Updated about 5 years ago