#!/usr/bin/php -q
<?php
function CallAPI($url, $data)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST,1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
));
$result = curl_exec($curl);
curl_close($curl);
return $result;
}
$key = '<CHANGE ME>';
$secret = '<CHANGE ME>';
$timestamp = time() * 1000;
$context_path = '/v1/search/masterfile?timestamp=' . $timestamp . '&key=' . $key;
$url = 'https://api.hmsonline.com' . $context_path;
// generate signature
$secret_bytes = base64_decode($secret);
$sig_hash = hash_hmac('sha1', $context_path, $secret_bytes, true);
$signature = base64_encode($sig_hash);
// add signature to URL
$url .= '&signature=' . $signature;
echo 'key = [' . $key . "]\n";
echo 'secret = [' . $secret . "]\n";
echo 'context_path = [' . $context_path . "]\n";
echo 'timestamp = [' . $timestamp . "]\n";
echo 'signature = [' . $signature . "]\n";
echo $url . "\n";
$data_string = '{"match_all":{}}';
$rslt = CallAPI($url,$data_string);
echo $rslt."\n";
?>