How to get Toky contacts list

Learn how to get a list of contacts from your Toky directory using our API

📘

API Endpoint used

/contacts

Parameters you need to replace in the getTokyContacts function:

<?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);
?>