GET Call Example in PHP

Call example »GET« in PHP
 
$identifier = '9b03c8cdf967d24a';
$private_key = '0a68ff8b77272baf5a04f3b656f27fb5250438bc21d7707515a1b506a3a8491b';
 
// GET params
$action = 'getSurveyResponseData';       // Function to execute
$survey_id = '7050';        // ID of survey
$params = '?usr_id=250235';        // other parameters needed for function execution
 
// Prepare data for hashing
$request_method = 'GET';
$request = 'https://www.1ka.si/api/'.$action.'/survey/'.$survey_id.$params;
 
$data = $request_method . $request;
 
// Calculate hash (token)
$token = hash_hmac('sha256', $data, $private_key);
 
// Prepare call – we add parameters 'identifier' and 'token'
$ch = curl_init($request.'&identifier='.$identifier.'&token='.$token);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $request_method);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 
// Execute call
$result = curl_exec($ch);
 

1KA is free to use for basic users